public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id()
@ 2024-07-24  7:10 Ma Ke
  2024-07-24 13:31 ` Greg KH
  2024-07-24 17:59 ` Avadhut Naik
  0 siblings, 2 replies; 3+ messages in thread
From: Ma Ke @ 2024-07-24  7:10 UTC (permalink / raw)
  To: kristo, bp, tony.luck, james.morse, mchehab, rric
  Cc: linux-edac, linux-kernel, Ma Ke, stable

In _emif_get_id(), of_get_address() may return NULL which is later
dereferenced. Fix this bug by adding NULL check.

Cc: stable@vger.kernel.org
Fixes: 86a18ee21e5e ("EDAC, ti: Add support for TI keystone and DRA7xx EDAC")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
Changes in v2:
- added Cc stable line.
---
 drivers/edac/ti_edac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
index 29723c9592f7..db23887b2d81 100644
--- a/drivers/edac/ti_edac.c
+++ b/drivers/edac/ti_edac.c
@@ -207,6 +207,9 @@ static int _emif_get_id(struct device_node *node)
 	int my_id = 0;
 
 	addrp = of_get_address(node, 0, NULL, NULL);
+	if (!addrp)
+		return -EINVAL;
+
 	my_addr = (u32)of_translate_address(node, addrp);
 
 	for_each_matching_node(np, ti_edac_of_match) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id()
  2024-07-24  7:10 [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id() Ma Ke
@ 2024-07-24 13:31 ` Greg KH
  2024-07-24 17:59 ` Avadhut Naik
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-07-24 13:31 UTC (permalink / raw)
  To: Ma Ke
  Cc: kristo, bp, tony.luck, james.morse, mchehab, rric, linux-edac,
	linux-kernel, stable

On Wed, Jul 24, 2024 at 03:10:42PM +0800, Ma Ke wrote:
> In _emif_get_id(), of_get_address() may return NULL which is later
> dereferenced. Fix this bug by adding NULL check.
> 
> Cc: stable@vger.kernel.org
> Fixes: 86a18ee21e5e ("EDAC, ti: Add support for TI keystone and DRA7xx EDAC")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> Changes in v2:
> - added Cc stable line.
> ---
>  drivers/edac/ti_edac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
> index 29723c9592f7..db23887b2d81 100644
> --- a/drivers/edac/ti_edac.c
> +++ b/drivers/edac/ti_edac.c
> @@ -207,6 +207,9 @@ static int _emif_get_id(struct device_node *node)
>  	int my_id = 0;
>  
>  	addrp = of_get_address(node, 0, NULL, NULL);
> +	if (!addrp)
> +		return -EINVAL;
> +

How was this found?

How was this tested?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id()
  2024-07-24  7:10 [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id() Ma Ke
  2024-07-24 13:31 ` Greg KH
@ 2024-07-24 17:59 ` Avadhut Naik
  1 sibling, 0 replies; 3+ messages in thread
From: Avadhut Naik @ 2024-07-24 17:59 UTC (permalink / raw)
  To: Ma Ke, kristo, bp, tony.luck, james.morse, mchehab, rric
  Cc: linux-edac, linux-kernel, stable

On 7/24/24 02:10, Ma Ke wrote:
> In _emif_get_id(), of_get_address() may return NULL which is later
> dereferenced. Fix this bug by adding NULL check.
> 
> Cc: stable@vger.kernel.org
> Fixes: 86a18ee21e5e ("EDAC, ti: Add support for TI keystone and DRA7xx EDAC")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> Changes in v2:
> - added Cc stable line.
> ---
>  drivers/edac/ti_edac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
> index 29723c9592f7..db23887b2d81 100644
> --- a/drivers/edac/ti_edac.c
> +++ b/drivers/edac/ti_edac.c
> @@ -207,6 +207,9 @@ static int _emif_get_id(struct device_node *node)
>  	int my_id = 0;
>  
>  	addrp = of_get_address(node, 0, NULL, NULL);
> +	if (!addrp)
> +		return -EINVAL;
> +
>  	my_addr = (u32)of_translate_address(node, addrp);
>  
>  	for_each_matching_node(np, ti_edac_of_match) {

IIUC, the original v2 submitted seems to differ from this RESEND patch
https://lore.kernel.org/linux-edac/20240718134834.826890-1-make24@iscas.ac.cn/

Snippet from submitting-patches:
Don’t add “RESEND” when you are submitting a modified version of your patch or patch series - “RESEND” only applies to resubmission of a patch or patch series which have not been modified in any way from the previous submission.

Any specific reason for this change?

From a brief look, it seems that the original v2 was correct.
Check for NULL pointer deference might be required in both places
in _emif_get_id().

Also, some more context on how this was noticed might help.
Was it through mere observation?

Thanks,
Avadhut Naik

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-24 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24  7:10 [PATCH v2 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id() Ma Ke
2024-07-24 13:31 ` Greg KH
2024-07-24 17:59 ` Avadhut Naik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox