From patchwork Tue Jan 11 20:13:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12710600 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 876D0C433F5 for ; Tue, 11 Jan 2022 20:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W+46Em/MwucTjzM0ZPzeDf6AkrUMHROUaI4OIdkca8I=; b=mdUQNQqu5lkulP XkwXNa7LEZ+MwF/mtolwKmFBrj7ZPeyczFTd+Z1Xv9Gb3QdIJekKlvm1fmZI8MWLtnmdWTkacRQH2 cWgAC0cG9iAI2TQ5UU3+rcbnvJpwe55Zq0aDPWCXqGwAwXWCBh0iJFAddeFrWexR7Rs5g0YNKsgLo 7LPrxY2RviWZZadENF/xL3XtOrnnYhTsGXVltwfMpNZBA+ldlbI4oE6aXZjn299VDvK5Qz3sOk/i5 dpE3yvtv8Nng6Pnq5P4HjyOZp2kbF7KNgLbXs+ESBZs+YfhH8Z8GdRLCsA6k7sHb6mUs6TiYH+3Pj 78CFlNnCiDXs8VoBLeGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7NYe-00HW3X-Db; Tue, 11 Jan 2022 20:15:52 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7NYD-00HVs8-PA for linux-arm-kernel@lists.infradead.org; Tue, 11 Jan 2022 20:15:28 +0000 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id A29C54076E for ; Tue, 11 Jan 2022 20:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1641932119; bh=d5pGhmqJ0JRQXzooQo2hGyeaXgPlX3UQHjrncRGcciU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wBJOjjswoGepclCBIAiGLhrqgneLa+bqBgnPgQSdVCGRU9a80LBwrggqL8tOGpKu3 AXaicg7fclnRAxmAdcmqZLAZp5eZWEK2ISVNLJeuPffORO1O5bim9fYICDrSUo+AHM EpoaaCASIAcHIgkDjFWMdM8P113TAa7oCWZHbaVlCg27d1faJ0cAWBzjMJrvAsmf7b +YnNm9fJeMtDmYr3p5rJROcPvgYOjxguV+8iZ4JTU+vFbnS/fX8SG4npRcTR++02hr En90iX9V7Yb9WSMLWJcwUgiw+oNb2aPcV5p2RLWUACeRKz6sgDVpuDaKc/0zEbs7qV 9a7GbPnGNSvMQ== Received: by mail-ed1-f69.google.com with SMTP id t1-20020a056402524100b003f8500f6e35so192736edd.8 for ; Tue, 11 Jan 2022 12:15:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d5pGhmqJ0JRQXzooQo2hGyeaXgPlX3UQHjrncRGcciU=; b=fMHeWebHB5zRyGvnthIKXNKS37EasvoYw7zuluUX5kMADPgKHu/CbtQo8/xyS28UOa 8zzNwoO8jQfyLY8TUGYCes4ISSWWv10VbPo25yNzDD+9crrrpRT60XneyAdbU1qLUiao o8O9xiiRQ6EBpqAINKK1q9TP6n/boCaxwTxHOlZl8Rk5Hj7buO/DUOwwPPURsz742NRz CXmWJo/AtmrjtipP4l93fBdfpFfMeavoU43n9IYD34Q8RjEx96SS2frjuK2GUiLMDsY1 GvrDFk2gydnIt+uFj27HqveiInUebjMzkkSOPZtpcPnGa5eArLFugK6A9Fwe/GwjxZwE BuzQ== X-Gm-Message-State: AOAM53388g6wEhdelUrg/eTff69iGFVDO6CwqOcMS8UDQl8Q1e32tOs9 oyn2RrIKS8dEXS220lRuuIz/GKXAsM89CE4dKcpghgGGK42Q9lFwDAD7Agn2ZsdCg/x0Dr4kNNp F9wlL/6moO3VruWZ8iHIn6NU/+GHCGCiPNSNThaOgCaHaynSzOM6f X-Received: by 2002:a17:907:ea2:: with SMTP id ho34mr4926903ejc.168.1641932117429; Tue, 11 Jan 2022 12:15:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVXIzemSiT3Glycmt0qLBDrfwwgWfKCYqgbL01msK36gJb1e8KFMLVuCJzheYC99dB0RaOlw== X-Received: by 2002:a17:907:ea2:: with SMTP id ho34mr4926894ejc.168.1641932117257; Tue, 11 Jan 2022 12:15:17 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-168-84.adslplus.ch. [188.155.168.84]) by smtp.gmail.com with ESMTPSA id f23sm3852212ejj.128.2022.01.11.12.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 12:15:16 -0800 (PST) From: Krzysztof Kozlowski To: Tomasz Figa , Krzysztof Kozlowski , Sylwester Nawrocki , Linus Walleij , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Sam Protsenko , Chanho Park , Alim Akhtar , stable@vger.kernel.org Subject: [PATCH v2 01/28] pinctrl: samsung: drop pin banks references on error paths Date: Tue, 11 Jan 2022 21:13:59 +0100 Message-Id: <20220111201426.326777-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220111201426.326777-1-krzysztof.kozlowski@canonical.com> References: <20220111201426.326777-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220111_121526_011565_77D1E3EF X-CRM114-Status: GOOD ( 18.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver iterates over its devicetree children with for_each_child_of_node() and stores for later found node pointer. This has to be put in error paths to avoid leak during re-probing. Fixes: ab663789d697 ("pinctrl: samsung: Match pin banks with their device nodes") Cc: Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chanho Park Reviewed-by: Sam Protsenko --- drivers/pinctrl/samsung/pinctrl-samsung.c | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 8941f658e7f1..b19ebc43d886 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -1002,6 +1002,16 @@ samsung_pinctrl_get_soc_data_for_of_alias(struct platform_device *pdev) return &(of_data->ctrl[id]); } +static void samsung_banks_of_node_put(struct samsung_pinctrl_drv_data *d) +{ + struct samsung_pin_bank *bank; + unsigned int i; + + bank = d->pin_banks; + for (i = 0; i < d->nr_banks; ++i, ++bank) + of_node_put(bank->of_node); +} + /* retrieve the soc specific data */ static const struct samsung_pin_ctrl * samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d, @@ -1116,19 +1126,19 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) if (ctrl->retention_data) { drvdata->retention_ctrl = ctrl->retention_data->init(drvdata, ctrl->retention_data); - if (IS_ERR(drvdata->retention_ctrl)) - return PTR_ERR(drvdata->retention_ctrl); + if (IS_ERR(drvdata->retention_ctrl)) { + ret = PTR_ERR(drvdata->retention_ctrl); + goto err_put_banks; + } } ret = samsung_pinctrl_register(pdev, drvdata); if (ret) - return ret; + goto err_put_banks; ret = samsung_gpiolib_register(pdev, drvdata); - if (ret) { - samsung_pinctrl_unregister(pdev, drvdata); - return ret; - } + if (ret) + goto err_unregister; if (ctrl->eint_gpio_init) ctrl->eint_gpio_init(drvdata); @@ -1138,6 +1148,12 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, drvdata); return 0; + +err_unregister: + samsung_pinctrl_unregister(pdev, drvdata); +err_put_banks: + samsung_banks_of_node_put(drvdata); + return ret; } /*