Message ID | b5b19cb458c40c9d02f3d5a7bd1ba7d97ba17279.1695077303.git.mirq-linux@rere.qmqm.pl |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3063230vqi; Mon, 18 Sep 2023 18:21:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjlovo6vUgMq+sh2LvRaAbE0yXESS+wUvZE1zJntN/dHRKF++MpY00Gi0jboDT8JlRGl9s X-Received: by 2002:a17:902:ab5d:b0:1c3:758d:32de with SMTP id ij29-20020a170902ab5d00b001c3758d32demr11155324plb.12.1695086500904; Mon, 18 Sep 2023 18:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695086500; cv=none; d=google.com; s=arc-20160816; b=1CA2DfkR4OvP48RID1vi6VHDD2oWnIL0Iah1wZnqykBbRB4rXDGNkyJBnH8sE8KF5B /KApk+vOv8Tb5iqH901ezunVQnpsw6jK8+JAdAY5sufnNcD6mK5dWSHPCknXPO9c4n2n eISvuToq6pv/EgRJfBnYwLtkSECrA8T3TewknGLoPSKymu4Vv7roLmkE6YP2MEHx7s4K 9JkxEzw0bJifx31F8XDdEnKEq3IyOdxmL7jqHAdZix+hTuk32ygIDXSINhpGl6TBptuh hvQVlVpFIzMFlRoIiQTsJHVV0noCLuJ9YhCNDzWtjzYyzX6qNd50issoDlUz1AcDrL5W xxSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:content-transfer-encoding :mime-version:subject:message-id:date:dkim-signature; bh=aq8IZw4EnPvG8wGweJYyymuvgmwQMwGW50sJmTgPPhQ=; fh=5FaU4Gy/yUbGXKmUVSyJFiklNAgn2uDS/ty3IIzMT2w=; b=TKcKN1xIdsarwgImpPoH1OnC4UHRwPVPCeVZuMsMjtf6halY2YRAgh6YWArHmCpDuf OLxL5goVu9dZFNC6g9tsbZ8WfQL67IBlgNZorDrteG3N+uSHLzXk8nbx77wtijzKzu+O M6zRIprRYWAE7tZIgTqAFj8Y3vhqpotvCXyHZktgwJzfpNo3URmuvxe1DB9OWpbosXgL c+tcCZvsDitFN9mqJlaFEPJL9sHduHu3mXcB7o5t9HT66o3WfS4EWuykqKctT88jaFp9 MHwZj39MkSn1Mod2t/jZryVffg/OMrTSPuuhukK4T2Sxe6nB8LAzPc+2Uu8cFT3ln28X DTew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=q0YT48w2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i17-20020a170902e49100b001bdd1f48f91si8682816ple.564.2023.09.18.18.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 18:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=q0YT48w2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 83326808D23B; Mon, 18 Sep 2023 15:50:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjIRWuk (ORCPT <rfc822;kernel.ruili@gmail.com> + 25 others); Mon, 18 Sep 2023 18:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjIRWug (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 18:50:36 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F6B8F for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 15:50:31 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4RqKkq2Hzcz60; Tue, 19 Sep 2023 00:50:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1695077427; bh=m2PiVkEVguzoRtvVnE00KO+PvS14T+9ORFLSvlRgRBk=; h=Date:Subject:From:To:Cc:From; b=q0YT48w2c6csMjFD0n5S6QeHMbP8tgLH8g9I8PyzkJTNeANJw3b4D7Yt0V/7OUjtm h5x5gJih5GNjueB0iZ2TmK8+p2n+l4jmlmIkvFQ2TVHSfm+1hMgC6cimuLbK9ogA5w 2RSi0wlugDx/en0AZz6Kxeiffdi9MjKNEZkXsCQOClndivlhRs1RCmPR8PSiEKogvu bh8igwB3/at3J6yd/HkMKIEJ38Kmnjn2NLlI6wFC6y0MAPHYzrdoazdpL17FQpZ8xX GjcbvKY21nfM3dmA+lNPKvUlafpRMJ4z7XiEl55BgEdTs+uNF/ql11fFsrxIM5rjw+ kkPLoB/jtY90A== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Tue, 19 Sep 2023 00:50:26 +0200 Message-Id: <b5b19cb458c40c9d02f3d5a7bd1ba7d97ba17279.1695077303.git.mirq-linux@rere.qmqm.pl> Subject: [PATCH v2 1/2] regulator/core: regulator_register: set device->class earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= <mirq-linux@rere.qmqm.pl> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org> Cc: Vladimir Zapolskiy <vz@mleia.com>, linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 15:50:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777427023156447224 X-GMAIL-MSGID: 1777427023156447224 |
Series |
[v2,1/2] regulator/core: regulator_register: set device->class earlier
|
|
Commit Message
Michał Mirosław
Sept. 18, 2023, 10:50 p.m. UTC
When fixing a memory leak in commit d3c731564e09 ("regulator: plug
of_node leak in regulator_register()'s error path") it moved the
device_initialize() call earlier, but did not move the `dev->class`
initialization. The bug was spotted and fixed by reverting part of
the commit (in commit 5f4b204b6b81 "regulator: core: fix kobject
release warning and memory leak in regulator_register()") but
introducing a different bug: now early error paths use `kfree(dev)`
instead of `put_device()` for an already initialized `struct device`.
Move the missing assignments to just after `device_initialize()`.
Fixes: d3c731564e09 ("regulator: plug of_node leak in regulator_register()'s error path")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2: move dev_set_drvdata() as it is used by regulator_dev_release()
+ move cover letter explanation to this patch
---
drivers/regulator/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Tue, 19 Sep 2023 00:50:26 +0200, Michał Mirosław wrote: > When fixing a memory leak in commit d3c731564e09 ("regulator: plug > of_node leak in regulator_register()'s error path") it moved the > device_initialize() call earlier, but did not move the `dev->class` > initialization. The bug was spotted and fixed by reverting part of > the commit (in commit 5f4b204b6b81 "regulator: core: fix kobject > release warning and memory leak in regulator_register()") but > introducing a different bug: now early error paths use `kfree(dev)` > instead of `put_device()` for an already initialized `struct device`. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next Thanks! [1/2] regulator/core: regulator_register: set device->class earlier commit: 8adb4e647a83cb5928c05dae95b010224aea0705 [2/2] regulator/core: Revert "fix kobject release warning and memory leak in regulator_register()" commit: 6e800968f6a715c0661716d2ec5e1f56ed9f9c08 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e1caaf207e..2820badc7a12 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5542,6 +5542,8 @@ regulator_register(struct device *dev, goto rinse; } device_initialize(&rdev->dev); + dev_set_drvdata(&rdev->dev, rdev); + rdev->dev.class = ®ulator_class; spin_lock_init(&rdev->err_lock); /* @@ -5603,11 +5605,9 @@ regulator_register(struct device *dev, rdev->supply_name = regulator_desc->supply_name; /* register with sysfs */ - rdev->dev.class = ®ulator_class; rdev->dev.parent = config->dev; dev_set_name(&rdev->dev, "regulator.%lu", (unsigned long) atomic_inc_return(®ulator_no)); - dev_set_drvdata(&rdev->dev, rdev); /* set regulator constraints */ if (init_data)