Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp58712pxy; Tue, 20 Apr 2021 12:33:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwByy0fAQqo9DetNbhPe5h252le+JcEBHHVuy//1b+wRB9p3+POGh74lqcZfg47XuGQYzr+ X-Received: by 2002:a63:a16:: with SMTP id 22mr4765089pgk.345.1618947238711; Tue, 20 Apr 2021 12:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618947238; cv=none; d=google.com; s=arc-20160816; b=DkH4+nyxBgn5mgCsBr0bbls2HU0zUtkZxhut6mEV4wvgwPxE83k7kITq9x0+QSpGcA JHpmS+0NI3AgX24Q8zKN96G64XcmrtMb7SbP7+3LRo9CxWl2Y0SSJhteePwVapbKgDZX nAIlgP0icRyaN+ooOR1colKh+eoeGZ77iTdzAsjslmtyQgBR4W981WF2oaSmBMuNPj4u AOv3wvo52/CQSWTsfeLRjC5ngJytayvT6qkKL8BPQ9tmuGIi4LIjmm89GaQCHcyzrNkq 2wLzRLnj35psbgvQO23+NmdQL+mBsJ4N8UkZ+8nJNagbZqiNk+ET9cHk1TUPUqbFLWfo 1saw== 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 :message-id:date:subject:cc:to:from; bh=TdEGTCbzPNYQkmPYALqA/UFHNrbaJagz6ai4NfwGq0Y=; b=gEyma6ALQvYz3Q6x/xdEDGNyJ/AJV8eQbPjOrkt8ryq4GcJMJYfYQ4z/jLvaJpSZ4I gHIrh+Z6zOUOwVL8nO0nr9UgWBaNdshTXJFp0q3CIIjbAc0F4Dq1FyMF6C7yEq+kgCsB 3a3ccGThLD+5CERDtRNYjoacFNF3mxUhLHqIo6tGi2r+mgu71RKiiSO2bjhfzCRCgg39 oL6Yj54FxLkU+s3qw81PAs3oh/nolkKrTkUZOcurrD4UGl67nMYpwfKVZ22jVs3+oGni L+a0eaTU9+GqRaT5JMaLClpYLMpbbu4SS+YxscYSVoQ4JFL8wGTsMYD7Vpw61txgVPFv wPUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si4051521pfd.37.2021.04.20.12.33.46; Tue, 20 Apr 2021 12:33:58 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233541AbhDTTc3 (ORCPT + 99 others); Tue, 20 Apr 2021 15:32:29 -0400 Received: from smtp11.smtpout.orange.fr ([80.12.242.133]:27197 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233544AbhDTTc2 (ORCPT ); Tue, 20 Apr 2021 15:32:28 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d34 with ME id v7Xu2400321Fzsu037XufV; Tue, 20 Apr 2021 21:31:55 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 20 Apr 2021 21:31:55 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: lgirdwood@gmail.com, broonie@kernel.org, ckeepax@opensource.cirrus.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()' Date: Tue, 20 Apr 2021 21:31:51 +0200 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'for_each_available_child_of_node()' already performs an 'of_node_get()' on child, so there is no need to perform another one before returning. Otherwise, a double 'get' is performed and a resource may never be released. Fixes: 925c85e21ed8 ("regulator: Factor out location of init data OF node") Signed-off-by: Christophe JAILLET --- Untested, speculative patch --- drivers/regulator/of_regulator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 564f928eb1db..49f6c05fee34 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -422,7 +422,11 @@ device_node *regulator_of_get_init_node(struct device *dev, if (!strcmp(desc->of_match, name)) { of_node_put(search); - return of_node_get(child); + /* + * 'of_node_get(child)' is already performed by the + * for_each loop. + */ + return child; } } -- 2.27.0