Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp715960pxb; Fri, 14 Jan 2022 14:51:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqm+TQlaLn4sUyPz+GsKFOF0RDjX7hYN+0L+GRrsKXJGOo0ltacUSoN7X5JIYB71kJcWcQ X-Received: by 2002:a63:e616:: with SMTP id g22mr9748251pgh.466.1642200674774; Fri, 14 Jan 2022 14:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642200674; cv=none; d=google.com; s=arc-20160816; b=JfJ4JOfpm0QEseTf1CUFy2eu7Zo7uVUY5uOSr1I2OQ4T/XOFUbXw0QJtGbLtJ7YXgM gsyg0+cdo4QL3NxqNYfpAfnQkZhiEqTT3n9PjpIYfrutqmsh0jMOi6wXGWdPwkT1eWIW zPctmrMyaS844248S9iLrlZAPAq1gZSHg63sT5GY5kWnDJ9fNfJF/peujOplcQy67/Hq hyPVvM16RuUQIm8QLoc8QmTAiX+W4VQlL6qYceJIVRJ8A1tuaDsXAk2RiD8qqnHmCKRw 2fiokp+u7D0lbp7RTxG7+3iYWj1pOsdO8i37O7r2XnA5yeR91OzaFzXzz/tD3o4GwLA+ XB+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kqh5lKYwnkN37kX/95ffH9A9xkW766WBUrIjfUiOtBY=; b=oy4URJqSQv6O1WjIEHz7oORaOQZ672r6F/nrlAG8fCyxdDMRP7puBUeopQb+4Is7P+ 34bcCurHkz2NaWM7obvywu7UrIeffpfW+dHysbc2Imc9Vk9EusrDHMN2dkhpO54Qd2FY yLVe5Lc4Por/ZZ5Sm+HpsNfBxC4zqR6Z1qQLscOLCjL3E/6YQ6HXg6PD26WpEcwiXNCk ZvmqRyl8Chz4RR7dT4QSChOdeikgisD38Nt4u/Mz16nxPgrydSEJcwGB4bl/Ym77Onw0 ynvLFpvWy8hfg+7jfMkHZE3w6Yj0FWF4VivyLYiuQXwCf6Uczi0SQxDp9AUQVikX00CD kuKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qYb0+aQJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si6191797pjv.156.2022.01.14.14.51.03; Fri, 14 Jan 2022 14:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qYb0+aQJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239298AbiANQiv (ORCPT + 99 others); Fri, 14 Jan 2022 11:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239309AbiANQiu (ORCPT ); Fri, 14 Jan 2022 11:38:50 -0500 Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C2D1C06161C for ; Fri, 14 Jan 2022 08:38:50 -0800 (PST) Received: by mail-ua1-x92e.google.com with SMTP id p37so17851629uae.8 for ; Fri, 14 Jan 2022 08:38:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kqh5lKYwnkN37kX/95ffH9A9xkW766WBUrIjfUiOtBY=; b=qYb0+aQJEJ0rzV5FWH45IVRX0rF7G6xG4H5zBgLJ5BQ0nYX8VUyDo1exod8NR+G70c uUhCkJ1oPjPsyO7yF5Xh+a2x8aWliDLS7AQahujnGlxHXRypN4/MRZu99b7pyB3Rrg5b eth+QoX5sOzDN8SgD3pxxH44+AK960G12fGA6WBa3UoXqRhf/9TgeD0hNVj1gNnkBMfz 8jGFnRU1nbOK5/NmPWgCO/S977btAOFBJy7GsekugUpkWpQqzt5UUUTnBciNQwSuEFMx 0qS7i4Vl7yHs4iKnthxTpjs3jdN1aJ2cr1k4+UtrielOfEPtCEM9NVxww1fD9eaeyqIj EFhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kqh5lKYwnkN37kX/95ffH9A9xkW766WBUrIjfUiOtBY=; b=KlTiNn5snAjOeClddZGTyMXfHq8fVfYdUgotpccxyvGlDxHafp6TZbjTuvDHAWKihg v1AJNcbxWWLCF8vCJrZKFatrRdAbwQT82hmO1KslqRLnjwgr/cGdP7CJGEzFxERpLzzU B2j9YPY5jiGT/VDzlmha4rAjAJQfAoD8T8XFPvwdHg3rNlFbwTPEZnCf+MqqcXTXVY/k okErs5zlwWkqft7rldYaEzhjNL8h6er59qXRUgXNkCWasNm6UL6A38Ijnkb9WM7Fh9+k SpB5OS8AUCPam0VboSUAszGon5Fz5TdRCB4nk9zZ3xlRVL5Uk+fsUepmIWQbDvIebCmL f25A== X-Gm-Message-State: AOAM532QcihwJDPSI63YkTfv6u27OZMdn2ztLfBLcXrJcVwTYeG+kDzu l4zpUA8f9kn+NKxqnZ/Je9gNBBCwouU0YFlsppK+BQ== X-Received: by 2002:a05:6102:108c:: with SMTP id s12mr4465397vsr.20.1642178329640; Fri, 14 Jan 2022 08:38:49 -0800 (PST) MIME-Version: 1.0 References: <20220111201426.326777-1-krzysztof.kozlowski@canonical.com> <20220111201426.326777-2-krzysztof.kozlowski@canonical.com> In-Reply-To: <20220111201426.326777-2-krzysztof.kozlowski@canonical.com> From: Sam Protsenko Date: Fri, 14 Jan 2022 18:38:37 +0200 Message-ID: Subject: Re: [PATCH v2 01/28] pinctrl: samsung: drop pin banks references on error paths To: Krzysztof Kozlowski Cc: Tomasz Figa , 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, Marek Szyprowski , Chanho Park , Alim Akhtar , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 Jan 2022 at 22:15, Krzysztof Kozlowski wrote: > > 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 > 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; > } > > /* > -- > 2.32.0 >