Skip to contentSkip to conversation

bq2415x_charger: Allow to load and use driver even if notify device is not registered yet

DISCUSSION Dan Carpenter 1 participant 1 message Sep 12, 2015

lore
Share & tools
lore
#0 lore raw

Hello Pali Rohár,

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

The patch b68c3161430a: "bq2415x_charger: Allow to load and use driver even if notify device is not registered yet" from Aug 11, 2015, leads to the following Smatch complaint:

drivers/power/bq2415x_charger.c:1707 bq2415x_probe()
error: we previously assumed 'bq' could be null (see line 1581)

drivers/power/bq2415x_charger.c
1580 bq = devm_kzalloc(&client->dev, sizeof(*bq), GFP_KERNEL);
1581 if (!bq) {
1582 ret = -ENOMEM;
1583 goto error_2;

"bq" is NULL.

1584 }

[ snip ]

  1702	error_4:
  1703		bq2415x_sysfs_exit(bq);
  1704	error_3:
  1705		bq2415x_power_supply_exit(bq);
  1706	error_2:
  1707		if (bq->notify_node)

Patch adds a dereference. Also the GW-BASIC label names are so ugly and inflexible, it's better to choose meaningful names that say what the label does like err_sysfs_exit, err_power_supply_exit, and err_node_put.

  1708			of_node_put(bq->notify_node);\
  1709		kfree(name);

regards,
dan carpenter