* [PATCH] mfd: sm501: Fix potential NULL pointer dereference
@ 2019-03-02 21:27 Aditya Pakki
2019-04-02 3:53 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-03-02 21:27 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, Lee Jones, linux-kernel
lookup variable on failure of allocating memory via devm_kzalloc
can cause a NULL pointer dereference. This patch avoids such a scenario.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/mfd/sm501.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index a530972c5a7e..e0173bf4b0dc 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1145,6 +1145,9 @@ static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm,
lookup = devm_kzalloc(&pdev->dev,
sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
GFP_KERNEL);
+ if (!lookup)
+ return -ENOMEM;
+
lookup->dev_id = "i2c-gpio";
if (iic->pin_sda < 32)
lookup->table[0].chip_label = "SM501-LOW";
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mfd: sm501: Fix potential NULL pointer dereference
2019-03-02 21:27 [PATCH] mfd: sm501: Fix potential NULL pointer dereference Aditya Pakki
@ 2019-04-02 3:53 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2019-04-02 3:53 UTC (permalink / raw)
To: Aditya Pakki; +Cc: kjlu, linux-kernel
On Sat, 02 Mar 2019, Aditya Pakki wrote:
> lookup variable on failure of allocating memory via devm_kzalloc
> can cause a NULL pointer dereference. This patch avoids such a scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> drivers/mfd/sm501.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied, thanks.
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-02 3:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-02 21:27 [PATCH] mfd: sm501: Fix potential NULL pointer dereference Aditya Pakki
2019-04-02 3:53 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).