From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B165C7EE24 for ; Mon, 1 May 2023 03:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbjEADAf (ORCPT ); Sun, 30 Apr 2023 23:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232376AbjEAC72 (ORCPT ); Sun, 30 Apr 2023 22:59:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A6C1BE5; Sun, 30 Apr 2023 19:58:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6322616F8; 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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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