From patchwork Fri Dec 31 16:19:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 529580 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 2A533C43219 for ; Fri, 31 Dec 2021 16:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbhLaQUS (ORCPT ); Fri, 31 Dec 2021 11:20:18 -0500 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:54852 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbhLaQUQ (ORCPT ); Fri, 31 Dec 2021 11:20:16 -0500 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) (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 C670E407AA for ; Fri, 31 Dec 2021 16:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1640967615; bh=Z5ioY/F3t7PzEeZt89hQh1G0ZQnghAHpzWba5N0rXNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d8877vxYZ2irgGdj3Ay4kG7kTqaXuGZgMIiEnWi7JH+Sjwhb3JG89ZrBFWj2dyWdd 2SxalkU2biu3E1xOvaaRTAYk+COQDzrsrzxheKWletirNIuAQY19NDmPr/8JWjVn54 409Gv/bK18FjOZk6vlNd4swKQ8TqBs/s9+0xeXv6EdRqR0YW34HEthgdYgviZkSIcT 8kjkNcxri+7ltWfleBVzbmUz2vuppfWFvDgCr0L72bMoxlkXtc/3NYnaJ/i26Qxi+v FWgMYr2eFolchVUul4yEIfvb4TTUygkDXudlRrA8zZQauox5iidk923BJuVL65zITu Ea9jEp+H5UClA== Received: by mail-lj1-f198.google.com with SMTP id b20-20020a2e9894000000b0022dc5a5f841so6413756ljj.2 for ; Fri, 31 Dec 2021 08:20:15 -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=Z5ioY/F3t7PzEeZt89hQh1G0ZQnghAHpzWba5N0rXNM=; b=l6y4Xa+3DuKD+mBV3phbKedYeuHBFyBsVbPep7FWDXKY5jn95BKxrz1edoZ6ZbA8so 90BFXx7pnkikg6QaZj8HnBnz4dzvKK9qtdotUPG79xdEWa1vJNMtgvKkACD0tKH+rJWN NiAHK6sDZ5DPeDk+LcBxCX+1rG2732pjJ+73iGZglPEWNBG8oT9yCWUSgHrNTuq8+F1/ pvn5dujpKWGl/dmTdQNDhMl7R92+Bq59kEuvfTZEEjGm/RLCE/HpJfefbOHQjnoqlakp d/lKmdfLFyS1ZJwLeQergkUORRv9kjn9SqiIT6EhQU9MW/w7z2JJIX7BLCURW+ZvpJxL JcXg== X-Gm-Message-State: AOAM532WpNftQ3M+v7y5NAY/rxVTjo9AScbgudmil+ePdCsEhTJ+xqea Ah7sdG7pspTc27W3CB0qCGPekeMngQ8TZiXiAc1yMmGMpUdJ8D5qIaQCBm2bhqG1MPlfE9njS3j LV4gy3++/MWb6k30rWDhWz1U31079Cxox52LUtOo= X-Received: by 2002:a05:651c:a09:: with SMTP id k9mr9172140ljq.180.1640967615144; Fri, 31 Dec 2021 08:20:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc+4kTYgqygG16URIJFVj2z6Z4ttRC0uwPhq5+1fKUZ9If5v0MZQV6COmgWUmppRWM7qDBog== X-Received: by 2002:a05:651c:a09:: with SMTP id k9mr9172134ljq.180.1640967614996; Fri, 31 Dec 2021 08:20:14 -0800 (PST) Received: from krzk-bin.lan (89-77-68-124.dynamic.chello.pl. [89.77.68.124]) by smtp.gmail.com with ESMTPSA id bx10sm2817607ljb.3.2021.12.31.08.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:20:14 -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 , Sylwester Nawrocki , Sam Protsenko , Chanho Park , stable@vger.kernel.org Subject: [PATCH 01/24] pinctrl: samsung: drop pin banks references on error paths Date: Fri, 31 Dec 2021 17:19:07 +0100 Message-Id: <20211231161930.256733-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211231161930.256733-1-krzysztof.kozlowski@canonical.com> References: <20211231161930.256733-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.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 --- drivers/pinctrl/samsung/pinctrl-samsung.c | 29 +++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 8941f658e7f1..f2864a7869b3 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -1002,6 +1002,15 @@ 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; + + 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 +1125,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 +1147,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; } /*