Skip to content

Commit ce02d82

Browse files
GustavoARSilvagregkh
authored andcommitted
mfd: sm501: Fix potential NULL pointer dereference
commit ae7b8ed upstream. There is a potential NULL pointer dereference in case devm_kzalloc() fails and returns NULL. Fix this by adding a NULL check on *lookup* This bug was detected with the help of Coccinelle. Fixes: b2e6355 ("i2c: gpio: Convert to use descriptors") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5579d97 commit ce02d82

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎drivers/mfd/sm501.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm,
11451145
lookup = devm_kzalloc(&pdev->dev,
11461146
sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
11471147
GFP_KERNEL);
1148+
if (!lookup)
1149+
return -ENOMEM;
1150+
11481151
lookup->dev_id = "i2c-gpio";
11491152
if (iic->pin_sda < 32)
11501153
lookup->table[0].chip_label = "SM501-LOW";

0 commit comments

Comments
 (0)