* [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback [not found] <20230501025632.3253067-1-sashal@kernel.org> @ 2023-05-01 2:56 ` Sasha Levin 2023-05-01 15:26 ` Uwe Kleine-König 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2023-05-01 2:56 UTC (permalink / raw) To: linux-kernel, stable Cc: Uwe Kleine-König, Hans Verkuil, Sasha Levin, mchehab, bleung, groeck, kevin.chiu.17802, scott_chao, zoey_wu, hellojacky0226, linux-media, chrome-platform From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [ Upstream commit 0ff7aee24e47beb4306ce050824b54147f2fabfa ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/media/cec/platform/cros-ec/cros-ec-cec.c | 10 ++++++---- 1 file 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 6ebedc71d67d4..960432230bbf1 100644 --- a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c +++ b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c @@ -332,14 +332,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); -- 2.39.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback 2023-05-01 2:56 ` [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback Sasha Levin @ 2023-05-01 15:26 ` Uwe Kleine-König 2023-05-18 17:02 ` Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Uwe Kleine-König @ 2023-05-01 15:26 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Hans Verkuil, mchehab, bleung, groeck, kevin.chiu.17802, scott_chao, zoey_wu, hellojacky0226, linux-media, chrome-platform [-- Attachment #1: Type: text/plain, Size: 1243 bytes --] Hello, On Sun, Apr 30, 2023 at 10:56:22PM -0400, Sasha Levin wrote: > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > [ Upstream commit 0ff7aee24e47beb4306ce050824b54147f2fabfa ] > > 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> > Signed-off-by: Sasha Levin <sashal@kernel.org> While I'm positive this change doesn't break anything, it also doesn't fix anything and is only cosmetic (+ preparing a later change). Unless you need it as a dependency I'd say, don't backport it for stable. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback 2023-05-01 15:26 ` Uwe Kleine-König @ 2023-05-18 17:02 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2023-05-18 17:02 UTC (permalink / raw) To: Uwe Kleine-König Cc: linux-kernel, stable, Hans Verkuil, mchehab, bleung, groeck, kevin.chiu.17802, scott_chao, zoey_wu, hellojacky0226, linux-media, chrome-platform On Mon, May 01, 2023 at 05:26:32PM +0200, Uwe Kleine-König wrote: >Hello, > >On Sun, Apr 30, 2023 at 10:56:22PM -0400, Sasha Levin wrote: >> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> >> >> [ Upstream commit 0ff7aee24e47beb4306ce050824b54147f2fabfa ] >> >> 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> >> Signed-off-by: Sasha Levin <sashal@kernel.org> > >While I'm positive this change doesn't break anything, it also doesn't >fix anything and is only cosmetic (+ preparing a later change). > >Unless you need it as a dependency I'd say, don't backport it for >stable. Ack, dropped. Thanks! -- Thanks, Sasha ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-18 17:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230501025632.3253067-1-sashal@kernel.org>
2023-05-01 2:56 ` [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback Sasha Levin
2023-05-01 15:26 ` Uwe Kleine-König
2023-05-18 17:02 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox