Skip to content

Commit 11741b8

Browse files
Dan Carpentersre
authored andcommitted
power: supply: max77705: Fix workqueue error handling in probe
The create_singlethread_workqueue() doesn't return error pointers, it returns NULL. Also cleanup the workqueue on the error paths. Fixes: a6a494c ("power: supply: max77705: Add charger driver for Maxim 77705") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 883730c commit 11741b8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/power/supply/max77705_charger.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,20 +545,28 @@ static int max77705_charger_probe(struct i2c_client *i2c)
545545
return dev_err_probe(dev, ret, "failed to add irq chip\n");
546546

547547
chg->wqueue = create_singlethread_workqueue(dev_name(dev));
548-
if (IS_ERR(chg->wqueue))
549-
return dev_err_probe(dev, PTR_ERR(chg->wqueue), "failed to create workqueue\n");
548+
if (!chg->wqueue)
549+
return dev_err_probe(dev, -ENOMEM, "failed to create workqueue\n");
550550

551551
ret = devm_work_autocancel(dev, &chg->chgin_work, max77705_chgin_isr_work);
552-
if (ret)
553-
return dev_err_probe(dev, ret, "failed to initialize interrupt work\n");
552+
if (ret) {
553+
dev_err_probe(dev, ret, "failed to initialize interrupt work\n");
554+
goto destroy_wq;
555+
}
554556

555557
max77705_charger_initialize(chg);
556558

557559
ret = max77705_charger_enable(chg);
558-
if (ret)
559-
return dev_err_probe(dev, ret, "failed to enable charge\n");
560+
if (ret) {
561+
dev_err_probe(dev, ret, "failed to enable charge\n");
562+
goto destroy_wq;
563+
}
560564

561565
return devm_add_action_or_reset(dev, max77705_charger_disable, chg);
566+
567+
destroy_wq:
568+
destroy_workqueue(chg->wqueue);
569+
return ret;
562570
}
563571

564572
static const struct of_device_id max77705_charger_of_match[] = {

0 commit comments

Comments
 (0)