From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83415361 for ; Mon, 1 May 2023 02:58:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9D5C4339B; Mon, 1 May 2023 02:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682909931; bh=hTYh1gt/OQMw4LzPSSg9pQwVxqfv+9i5wbpULGqbev8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxBtjN9j9fABt/HNcd6rft58KvziDrJ7jL27//AsZJPQSl6nj72AO3Jdw5oyvs2GE AcG2gN/Old7fvCMOQC2QwPayyR/fFYFZz7dBfbVL20EHSMCKv5fJ74s+WBjD0LOXwK c2DS6rONMY6d3BQlwrAZoM2VTy9/Do9el4FxYyC7wKsh4myvsmalB1pSq+vOflEMi3 vZCgpd00CvzvVRr6692b4Da5oU8t3Irg+NF0SAaKA6h797xqxsRXePdLEB0ag2rK3f Hl/U8ixmZ+KWHhfAfEpK85wfv6uOjane0pAFBKqEevgxmAtOBTCX52Zm/N+mz8oUsg X6Xi23eV5xggQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Hans Verkuil , Sasha Levin , mchehab@kernel.org, bleung@chromium.org, groeck@chromium.org, kevin.chiu.17802@gmail.com, scott_chao@wistron.corp-partner.google.com, zoey_wu@wistron.corp-partner.google.com, hellojacky0226@hotmail.com, linux-media@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH AUTOSEL 6.3 34/44] media: cros-ec-cec: Don't exit early in .remove() callback Date: Sun, 30 Apr 2023 22:56:22 -0400 Message-Id: <20230501025632.3253067-34-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501025632.3253067-1-sashal@kernel.org> References: <20230501025632.3253067-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Uwe Kleine-König [ 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 Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- 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