Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2821532pxb; Mon, 18 Apr 2022 08:57:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8fjUqyE3DaoazBIBndKw8R5i1/tAbZUnXDFDAgAxY9ul9E2jbetXYvUE0jpLT8cSANban X-Received: by 2002:a05:6a00:178e:b0:508:2073:f635 with SMTP id s14-20020a056a00178e00b005082073f635mr13014491pfg.10.1650297449551; Mon, 18 Apr 2022 08:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650297449; cv=none; d=google.com; s=arc-20160816; b=feAMUIv8IfAgSeYA/gKYnFbjIr0SKvNKTY1bwBUCcCzkjGv/s0HBRe6eoITXJeOrEE 1V79zz/lx9egpDzxalXsOnQcVoPNXZLD0mgk7fVMatB5Igwu/vZeY9sSDXzuIJAE3vL6 gEr5cPBewNjXTf4GEcgaO1OpTP5cCeoXGPmPEM6/fZwkcNfNAl3pxMupHuzsET4RnOqe rg3di47Z4dAY4uCgHCZcmUqnZu5BfDkI05tup34CVPqUpJlYeXpNJmi8GqS1fgkSVv4t 4QwGFy76DYoWyTQ9c5/MHhLJ9PASUmMiaKNy/Ta5AAO+++U96w5sgsv/yjm+E4QRgwyY OdxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W1MuMLKegzBZItVTkfJCV8PUa86zvAzlKw3gu2hYywI=; b=w9I8iEshWxAzjqVJtMr/SY9fu7fqEP3ThKSSXuDy2UF2R8axn6PNChvZa+02H3pSuw a983DokQjsnzia9owCZd/0Jqo05Jx8piWA8tMwxdkmn35stC8PnIa5W/HJWVgKsNvFCv ZqfpggUA0jXQaT3O9y50i5VWjNw7OtBgTK/mbl2p3Zyiol9oZpoo60vD1/70ALBLkVv7 mLrS9anF92c6uc6yUWXnG6oaWCoKGO5llPwSWTVFRAkuVa/R+UngSOnys+RLbeRXKD0V +03iHmC/eakXKCi/vVWbKy98Eta3Xt95KKsDUDwrJcww1rchNXc9gSi7qTYYf4hvQ5Jo dAcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lRmzWHVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l64-20020a638843000000b003816043efecsi9215795pgd.481.2022.04.18.08.57.12; Mon, 18 Apr 2022 08:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lRmzWHVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243189AbiDRNhc (ORCPT + 99 others); Mon, 18 Apr 2022 09:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241867AbiDRNIe (ORCPT ); Mon, 18 Apr 2022 09:08:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70E42C655; Mon, 18 Apr 2022 05:48:06 -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 2FE3961268; Mon, 18 Apr 2022 12:48:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24C6BC385A7; Mon, 18 Apr 2022 12:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286085; bh=q1vKdk3kHmzjciSUyf4Qz2XI3CxCsuIyWQCjFJhdjUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRmzWHVxW/MQ+YHgMGIShwiN50PuL8WByPkmhva/w6XNefmJ6TUXAx4Nmgfi///df tR/+yaBp7jeQfQcVG/X8B1GT4rJa4EqXSQg31yFDNwtPz6Pl4Jd3aWeg/LNiypb3r2 UcTnppXLx2xCXlpdP17WtqKZfP+pzMrszyGVIbk4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Sam Protsenko , Chanho Park Subject: [PATCH 4.14 024/284] pinctrl: samsung: drop pin banks references on error paths Date: Mon, 18 Apr 2022 14:10:05 +0200 Message-Id: <20220418121211.384754947@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Krzysztof Kozlowski commit 50ebd19e3585b9792e994cfa8cbee8947fe06371 upstream. 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: Sam Protsenko Reviewed-by: Chanho Park Link: https://lore.kernel.org/r/20220111201426.326777-2-krzysztof.kozlowski@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/samsung/pinctrl-samsung.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -975,6 +975,16 @@ samsung_pinctrl_get_soc_data_for_of_alia 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, @@ -1089,19 +1099,19 @@ static int samsung_pinctrl_probe(struct 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); @@ -1111,6 +1121,12 @@ static int samsung_pinctrl_probe(struct 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; } /**