Skip to contentSkip to conversation

pcf857x_probe() error: we previously assumed 'pdata' could be null (see line 277)

PATCH Applied Fengguang Wu 3 participants 5 messages Sep 12, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

FYI, there are new smatch warnings on

commit 6e20a0a429bd4dc07d6de16d9c247270e04e4aa0 gpio: pcf857x: enable gpio_to_irq() support

drivers/gpio/gpio-pcf857x.c:288 pcf857x_probe() error: we previously assumed 'pdata' could be null (see line 277) drivers/gpio/gpio-pcf857x.c:364 pcf857x_probe() warn: variable dereferenced before check 'pdata' (see line 292) drivers/gpio/gpio-pcf857x.c:421 pcf857x_remove() error: we previously assumed 'pdata' could be null (see line 410)

---
0-DAY kernel build testing backend Open Source Technology Centre
Fengguang Wu <[email protected]> Intel Corporation

#1 lore raw

PATCH 1/1 gpio: pcf857x: fixup smatch WARNING

6e20a0a429bd4dc07d6de16d9c247270e04e4aa0
(gpio: pcf857x: enable gpio_to_irq() support)
added new smatch warnings

drivers/gpio/gpio-pcf857x.c:288 pcf857x_probe() error: we previously \
assumed 'pdata' could be null (see line 277)
drivers/gpio/gpio-pcf857x.c:364 pcf857x_probe() warn: variable dereferenced\
before check 'pdata' (see line 292)
drivers/gpio/gpio-pcf857x.c:421 pcf857x_remove() error: we previously\
assumed 'pdata' could be null (see line 410)

This patch fixes it

---
 drivers/gpio/gpio-pcf857x.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-pcf857x.c +3 -3
index 12e3e48..16af35c 100644
@@ -285,7 +285,7 @@ static int pcf857x_probe(struct i2c_client *client,
 	gpio->chip.ngpio		= id->driver_data;
 
 	/* enable gpio_to_irq() if platform has settings */
-	if (pdata->irq) {
+	if (pdata && pdata->irq) {
 		status = pcf857x_irq_domain_init(gpio, pdata, &client->dev);
 		if (status < 0) {
 			dev_err(&client->dev, "irq_domain init failed\n");
@@ -394,7 +394,7 @@ fail:
 	dev_dbg(&client->dev, "probe error %d for '%s'\n",
 			status, client->name);
 
-	if (pdata->irq)
+	if (pdata && pdata->irq)
 		pcf857x_irq_domain_cleanup(gpio);
 
 	kfree(gpio);
@@ -418,7 +418,7 @@ static int pcf857x_remove(struct i2c_client *client)
 		}
 	}
 
-	if (pdata->irq)
+	if (pdata && pdata->irq)
 		pcf857x_irq_domain_cleanup(gpio);
 
 	status = gpiochip_remove(&gpio->chip);
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Fengguang Wu
Quoted 7 lines · Fengguang Wu

FYI, there are new smatch warnings on

commit 6e20a0a429bd4dc07d6de16d9c247270e04e4aa0 gpio: pcf857x: enable gpio_to_irq() support

drivers/gpio/gpio-pcf857x.c:288 pcf857x_probe() error: we previously assumed 'pdata' could be null (see line 277) drivers/gpio/gpio-pcf857x.c:364 pcf857x_probe() warn: variable dereferenced before check 'pdata' (see line 292) drivers/gpio/gpio-pcf857x.c:421 pcf857x_remove() error: we previously assumed 'pdata' could be null (see line 410)

OK Kuninoiri can you have a look at this and see if you can fix it up?

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH] gpio: pcf857x: fixup smatch WARNING

In reply to Kuninori Morimoto
Quoted 11 lines · Kuninori Morimoto

6e20a0a429bd4dc07d6de16d9c247270e04e4aa0
(gpio: pcf857x: enable gpio_to_irq() support)
added new smatch warnings

drivers/gpio/gpio-pcf857x.c:288 pcf857x_probe() error: we previously \
assumed 'pdata' could be null (see line 277)
drivers/gpio/gpio-pcf857x.c:364 pcf857x_probe() warn: variable dereferenced\
before check 'pdata' (see line 292)
drivers/gpio/gpio-pcf857x.c:421 pcf857x_remove() error: we previously\
assumed 'pdata' could be null (see line 410)

Quoted 4 lines

This patch fixes it

Applied, thanks!
Linus Walleij