[bug report] mfd/htc-i2cpld.c wrong check in htcpld_chip_get()

From: Dan Carpenter
Date: Sun Dec 19 2010 - 15:58:32 EST


Hi Cory,

Smatch complains that the check is wrong on line 280 from
drivers/mfd/htc-i2cpld.c

drivers/mfd/htc-i2cpld.c +280 htcpld_chip_get(12)
warn: can 'chip_data' even be NULL?

278 /* Try out first */
279 chip_data = container_of(chip, struct htcpld_chip, chip_out);
280 if (!chip_data) {
281 /* Try in */
282 is_input = 1;
283 chip_data = container_of(chip, struct htcpld_chip, chip_in);
284 if (!chip_data)
285 return -EINVAL;
286 }

container_of() takes the chip pointer and subtracts a small number (it
subtracts the offset of the chip_out element from the start of the
htcpld_chip struct). So basically it's never NULL. I'm not sure what
the correct check should be here, can you take a look?

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/