Skip to contentSkip to conversation

i2c: pxa: add OF support

DISCUSSION Dan Carpenter 1 participant 1 message Nov 6, 2013 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hello Haojian Zhuang,

This is a semi-automatic email about new static checker warnings.

The patch 63fe122bce06: "i2c: pxa: add OF support" from Mar 1, 2012, leads to the following Smatch complaint:

drivers/i2c/busses/i2c-pxa.c:1272 i2c_pxa_probe()
error: we previously assumed 'res' could be null (see line 1161)

drivers/i2c/busses/i2c-pxa.c
1160 irq = platform_get_irq(dev, 0);

  1161		if (res == NULL || irq < 0) {
                    ^^^^^^^^^^^

Patch introduces a new error path.

  1162			ret = -ENODEV;
  1163			goto eclk;
  1164		}
  1165	

[snip]

1267 eremap:
1268 clk_put(i2c->clk);
1269 eclk:
1270 kfree(i2c);
1271 emalloc:

  1272		release_mem_region(res->start, resource_size(res));
                                   ^^^^^^^^^^  ^^^^^^^^^^^^^^^^^

Null dereferences.

Obviously the unwind needs to be fixed so it's a mirror reflection of the allocation order. Also the labels are crap. Label names should be based on the label location and not the goto location(s).

1273 return ret;
1274 }

regards,
dan carpenter