* [PATCH v3 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id()
@ 2024-08-02 4:41 Ma Ke
2024-08-02 6:11 ` Naik, Avadhut
0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-08-02 4:41 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.
Found by code review.
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 v3:
- added the patch operations omitted in PATCH v2 RESEND compared to PATCH
v2. Sorry for my oversight.
Changes in v2:
- added Cc stable line.
---
drivers/edac/ti_edac.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
index 29723c9592f7..6f3da8d99eab 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) {
@@ -214,6 +217,9 @@ static int _emif_get_id(struct device_node *node)
continue;
addrp = of_get_address(np, 0, NULL, NULL);
+ if (!addrp)
+ return -EINVAL;
+
addr = (u32)of_translate_address(np, addrp);
edac_printk(KERN_INFO, EDAC_MOD_NAME,
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v3 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id()
2024-08-02 4:41 [PATCH v3 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id() Ma Ke
@ 2024-08-02 6:11 ` Naik, Avadhut
0 siblings, 0 replies; 2+ messages in thread
From: Naik, Avadhut @ 2024-08-02 6:11 UTC (permalink / raw)
To: Ma Ke, kristo, bp, tony.luck, james.morse, mchehab, rric
Cc: linux-edac, linux-kernel, stable
On 8/1/2024 23:41, Ma Ke wrote:
> In _emif_get_id(), of_get_address() may return NULL which is later
> dereferenced. Fix this bug by adding NULL check.
>
> Found by code review.
>
> 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 v3:
> - added the patch operations omitted in PATCH v2 RESEND compared to PATCH
> v2. Sorry for my oversight.
> Changes in v2:
> - added Cc stable line.
> ---
> drivers/edac/ti_edac.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
> index 29723c9592f7..6f3da8d99eab 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) {
> @@ -214,6 +217,9 @@ static int _emif_get_id(struct device_node *node)
> continue;
>
> addrp = of_get_address(np, 0, NULL, NULL);
> + if (!addrp)
> + return -EINVAL;
> +
> addr = (u32)of_translate_address(np, addrp);
>
> edac_printk(KERN_INFO, EDAC_MOD_NAME,
In [1], you are fixing possible NULL pointer dereferences arising from
of_get_address() and of_translate_address()
In this patch, however, you are only attempting to fix possible NULL
pointer dereferences arising from of_get_address().
Any reason why of_translate_address() doesn't need to be fixed here?
Also, since [1] and this patch are addressing possible NULL pointer
dereferences from similar functions, you may want to club them
together as a single patchset. Makes its easier for people to review.
[1]: https://lore.kernel.org/linux-edac/7021a08b-ba75-4d16-a71f-b38e48df5af3@amd.com/T/#t
--
Thanks,
Avadhut Naik
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-02 6:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-02 4:41 [PATCH v3 RESEND] EDAC/ti: Fix possible null pointer dereference in _emif_get_id() Ma Ke
2024-08-02 6:11 ` Naik, Avadhut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®