diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-03-26 17:30:29 +0300 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2023-04-11 17:59:13 +0300 |
commit | 0ff7aee24e47beb4306ce050824b54147f2fabfa (patch) | |
tree | 4e119ff01dc0367ab49ae75682a545a8f1911b77 /drivers/media/cec/platform | |
parent | 4948ea58e7335e00d6556f884151b0dae1fb344f (diff) | |
download | linux-0ff7aee24e47beb4306ce050824b54147f2fabfa.tar.xz |
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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media/cec/platform')
-rw-r--r-- | drivers/media/cec/platform/cros-ec/cros-ec-cec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c index 7c327fa8bff4..3525ed8f4fc1 100644 --- a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c +++ b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c @@ -338,14 +338,16 @@ static int cros_ec_cec_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; 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( &cros_ec_cec->cros_ec->event_notifier, &cros_ec_cec->notifier); - - if (ret) { + if (ret) dev_err(dev, "failed to unregister notifier\n"); - return ret; - } cec_notifier_cec_adap_unregister(cros_ec_cec->notify, cros_ec_cec->adap); |