Commit 0ff7aee2 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Hans Verkuil

media: cros-ec-cec: Don't exit early in .remove() callback

Exiting early in remove without releasing all acquired resources yields
leaks. Note that e.g. memory allocated with devm_zalloc() is freed after
.remove() returns, even if the return code was negative.

While blocking_notifier_chain_unregister() won't fail and so the
change is somewhat cosmetic, platform driver's .remove callbacks are
about to be converted to return void. To prepare that, keep the error
message but don't return early.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 4948ea58
...@@ -338,14 +338,16 @@ static int cros_ec_cec_remove(struct platform_device *pdev) ...@@ -338,14 +338,16 @@ static int cros_ec_cec_remove(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
/*
* blocking_notifier_chain_unregister() only fails if the notifier isn't
* in the list. We know it was added to it by .probe(), so there should
* be no need for error checking. Be cautious and still check.
*/
ret = blocking_notifier_chain_unregister( ret = blocking_notifier_chain_unregister(
&cros_ec_cec->cros_ec->event_notifier, &cros_ec_cec->cros_ec->event_notifier,
&cros_ec_cec->notifier); &cros_ec_cec->notifier);
if (ret)
if (ret) {
dev_err(dev, "failed to unregister notifier\n"); dev_err(dev, "failed to unregister notifier\n");
return ret;
}
cec_notifier_cec_adap_unregister(cros_ec_cec->notify, cec_notifier_cec_adap_unregister(cros_ec_cec->notify,
cros_ec_cec->adap); cros_ec_cec->adap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment