Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp472703lqm; Wed, 1 May 2024 06:33:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGneesByAOynXYgCgrPpFTybyhFhkc9XcjoNyjUzDPM00PZUS/PIGIg9ePujQwSUx9/LDJTdbqLtNQ0E58bXxUOzzR3dwghsrmv7uWYQ== X-Google-Smtp-Source: AGHT+IEhGatbDe8Dp0m2Fg7QLYJmjOixiLvc5k/zfASxHFhW1JxLVVlsVaw8UuU1PNNAZSbqq8Pe X-Received: by 2002:a05:6a00:3982:b0:6f3:f447:57de with SMTP id fi2-20020a056a00398200b006f3f44757demr2771893pfb.19.1714570381709; Wed, 01 May 2024 06:33:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714570381; cv=pass; d=google.com; s=arc-20160816; b=x0tr8vaEBFv8Ca3Eu2s9D8htQ+iuJ1FJo2hBVgVZkOaTYBW4AQ+UzTKAe+o1TERtuu c6yx+gzruan2sE1NxmRz4feIxY63eL6HmoxqRPqb3vaGdhQHZYGu/Inke6mTO0loFK1s 2S+fv2nSPVOF/+eqSeCW1xvl/C9G+O4waX75LhIRP6pcnjVSawOpcY6KsWR+zYb5D1JL YB8rLO4LDbqa/5ePPpFjzwA6K+uwNPCr82WozI2QPtd9rWCWaGz63pHcww5r01N41A3q GMPMw19RNG+Xn8O4iwfTUeAUDmQaAQij4kXrDaCMfwTMIkbL/n3EccSRjLC1Mnh+PHZs Bknw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ior2gPFVlEOyeV8FJQcXfdx4VXM0R/609sKh6Of53VM=; fh=xTYFql0qY6czfx0jnthL3o2h9GrLQHNRFyglP2m/bf8=; b=vTKNr7cgdg4pcuU/QJG66ieI+FQtuL71LPXnZrcaJvrfjEXqhNg+8MjO/VRXdzxyMA OWMcks0vS+GTTwD9MwOaGMhGIgMl7cN6o3NzODYbBQU4XReAA7yASK8+K5lX288j5ojX we5e5AP9nOoxCjDFVovT3Y25KTa9r/K/Rhf1BJfDPmSmr90iQaU+DJHcFoRSQpSWRCki A4qKZAYO9PDZIcrHic7YRBZZmI7E1/UZGJ4c2tSB+5sHRBDo9xgbC/MvuXBUd8QSPa4g aKdAmRjRUhmvOwJviRoShvPorySFvO/1O+PZWXTXHRBbYhJxAp6ZuYkFDczi2Qf51O5r QdaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F6vq4feq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-165320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165320-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k124-20020a633d82000000b005f9099588d9si20087898pga.717.2024.05.01.06.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 06:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F6vq4feq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-165320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165320-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3B4CD28275C for ; Wed, 1 May 2024 13:33:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6100612EBC5; Wed, 1 May 2024 13:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F6vq4feq" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5313812DDBC for ; Wed, 1 May 2024 13:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714570373; cv=none; b=XD/S82V7+H07fKoxUSroZa6nFTPamPvEVslez9Fn1YJ6mKivsv45mxVKLc6Y8eft0ijVCUluAf9Y3hvqz7A7/F5jail91dAzvWPw+8R/mZTok+fXAMRCayan3KzdL4IxsbYesjKGSPs+4gqucfgGC/VadOye1CTywSTxj+bqKpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714570373; c=relaxed/simple; bh=ZqcDVgO1hmm+00KuoWmbr7W1NZLQvg1QhUiwr8SEKP0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QLxe0N2aSztik36UFqDXwOY/wnY78aBWRY1YN4AkVJuNzODrnOdgGSKlwPrfrqaxpRgs+BWZb4WKZ84WolZ40jUeb8khN6V06UcYYPyHcOisOHOfHGpmmeegzl0TbwICa05iILLgcEZ75xgWdKzmgBPwI381tbXTikAP4vDDq34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=F6vq4feq; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-34dc9065606so334682f8f.1 for ; Wed, 01 May 2024 06:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714570370; x=1715175170; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ior2gPFVlEOyeV8FJQcXfdx4VXM0R/609sKh6Of53VM=; b=F6vq4feq2N5K6oTj556OwcPXVHZ7iw0HaZm1/3fK7K35ZYPLVA0aEuiko5H4MqYkQh qSe5VEjBpSX5FByvdImvMsfRPr6G+ZrVMz0YoI/HbJ3QeVzdcsCZ6ZekbH6GTvtKEgj1 WBCFyOatej8cYNzphRSYOmgr3QN/8q7hkrGHzYwN2POMuPVHWKe9DGe0pKFAEUO1l1t6 mWgb4K4+leSysSgczOEMCz+aChc6vudaAWSlV36rkLHpFSd8ZfJb/sGN0wvi8bxq04eA vcRNjkl/2HVD/Q82Qhv9vnhuCGOS9syNHALjM4eJ72PUF/+Nuxe0rEm7F19s8DlUBlhg xPaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714570370; x=1715175170; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ior2gPFVlEOyeV8FJQcXfdx4VXM0R/609sKh6Of53VM=; b=cPa4a6OEExtJJRjVuUWnj5KtYThQtHzojT44SuqKh8utsPVMciTP4bQQwdBI8mzOJ9 agDsDmcVBH51wo7CQMaL5/I5G/d938k/FA+fbgwzboi7yHKcmMwtgXdJ1lGyIaCWx8q/ OqWWpB62S//GqDhGG8XgYE508JmUOO8+0PNqBOPvAdbItingjRZxnsdqI8VL1qVDBnI/ zKdfcncCuV+sM4XgCuc788BPYFBvDqnCVB6CP1OHKpIpFerncEOzUF0y4Ozr1YjTr9Pa FE2hoYBdscJP6LzIT5K0RDl1YP8q3qyX84tTS6FOh68x04KwZP7asupBO7MMNB9lBpyl BF0g== X-Forwarded-Encrypted: i=1; AJvYcCUqf8I7vXzoA7nCxEp4QSbf9aanEi7PhDXyWP3EBfVsRca+WUQgRqSCyAMs3tI3Wq0WTU7WOA5ANNi1LFOyTvZzmZcwx3XYv06aO8k7 X-Gm-Message-State: AOJu0YySZNX+7dnNysz3Yp5CSWiU4la6DMwCZSu9a9VSEXCs8POp5XtZ aHrVq8lLJMPXLH0LPff4cYRJ0PFYZYCAYqqTcixnMO1Q6nB86w7MJqVBiWJ+W7A= X-Received: by 2002:a05:6000:24f:b0:34c:bf22:73f9 with SMTP id m15-20020a056000024f00b0034cbf2273f9mr2265612wrz.28.1714570369370; Wed, 01 May 2024 06:32:49 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id d4-20020adfe2c4000000b0034a3a0a753asm32876234wrj.100.2024.05.01.06.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 06:32:49 -0700 (PDT) Date: Wed, 1 May 2024 16:32:40 +0300 From: Dan Carpenter To: "Peng Fan (OSS)" Cc: Linus Walleij , Thierry Reding , Jonathan Hunter , Dvorkin Dmitry , Wells Lu , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Jianlong Huang , Hal Feng , Orson Zhai , Baolin Wang , Chunyan Zhang , Viresh Kumar , Shiraz Hashim , soc@kernel.org, Krzysztof Kozlowski , Sylwester Nawrocki , Alim Akhtar , Geert Uytterhoeven , Patrice Chotard , Heiko Stuebner , Damien Le Moal , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Chester Lin , Matthias Brugger , Ghennadi Procopciuc , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Sascha Hauer , Andrew Jeffery , Joel Stanley , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mediatek@lists.infradead.org, imx@lists.linux.dev, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Peng Fan Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups Message-ID: References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> <20240501-pinctrl-cleanup-v1-1-797ceca46e5c@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501-pinctrl-cleanup-v1-1-797ceca46e5c@nxp.com> On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote: > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev) > ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl); > if (ret) { > dev_err(dev, "Failed to register pinctrl\n"); > - goto exit_out; > + return ret; > } > > platform_set_drvdata(pdev, iod); > > return pinctrl_enable(iod->pctl); > - > -exit_out: > - of_node_put(np); > - return ret; > } This will call of_node_put() on the success path so it's a behavior change. The original code is buggy, it's supposed to call of_node_put() on the success path here or in ti_iodelay_remove(). If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's supposed to call it in ti_iodelay_remove() then we need to save the pointer somewhere using no_free_ptr(). Probably saving ->np is the safest choice? The original code is already a little bit buggy because it doesn't check for pinctrl_enable() errors and cleanup. diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index 040f2c46a868..f40a1476e4ff 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -156,6 +156,7 @@ struct ti_iodelay_device { const struct ti_iodelay_reg_data *reg_data; struct ti_iodelay_reg_values reg_init_conf_values; + struct device_node *np; }; /** @@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device *pdev) platform_set_drvdata(pdev, iod); - return pinctrl_enable(iod->pctl); + ret = pinctrl_enable(iod->pctl); + if (ret) + goto exit_out; + + iod->np = no_free_ptr(np); + return 0; exit_out: of_node_put(np); @@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device *pdev) pinctrl_unregister(iod->pctl); ti_iodelay_pinconf_deinit_dev(iod); + of_node_put(iod->np); /* Expect other allocations to be freed by devm */ }