From patchwork Sun Sep 17 21:35:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 141232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2396430vqi; Sun, 17 Sep 2023 19:32:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG46uX6t8rE0y4N7v2/L1X05NhmhLNQzVIxmdw9CoZmwTWtmVUNNp6bQmpQTK23/d9GDwnn X-Received: by 2002:a9d:68c5:0:b0:6b9:ed64:1423 with SMTP id i5-20020a9d68c5000000b006b9ed641423mr8516980oto.2.1695004367804; Sun, 17 Sep 2023 19:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695004367; cv=none; d=google.com; s=arc-20160816; b=zQWneS313WfcBj/Eu7FNaiTZXaihmY4M6PhmbMPxblZyk2foODHFcx27lHHiSeY9V9 jiviLHSAAszCLlSQRxOFZSjf2Nin1/nOQUfplt814RjneViocq45NJHkHMeXDZWmsaM3 6sRx3H+a62WNbFNIMKsyuKud1OAOv4KaEbR0P0GG99ll60Djtn0IMzjDtWsStFs2nbOR BR2jAxIui/WuQk+rXQyOH6499H3OnM98ZTlpZ6Lrw+Tc4M3Y8Lx5y6D/XSllYi3JGoXF 49yUuZkdOwhNjVzDLfZ610b0YFedDqUX21IGk56DfnrdXyEs9dISLUlYGsj1rKS6EirV EdOg== 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:references:in-reply-to:message-id:date :dkim-signature; bh=5rpYCOf0cpZpYVSl/vYkYPGX4GWoCDvDzjYG43Zrk3g=; fh=mSeKGAqrJ1t/2zVIl3WHRQHhiVbNlwbe/HuGR3A2uBQ=; b=HjbZv1ttwJJweEO2DctF7tG+Ls3ZMs9gjSEcs5pKjL7cA9cZVRQukezS/PAFAAwGot N8R4bGe8jerzR5/ZaeXgoUiRyTjsSTYAV9DLO725m+oq6B68SFHzYmNG7+WYdAr2f5yv Q3EMAU2B5iYu4Q5pkUjE5P4Bch3nqm8wWWUoWV+t4/+j6ceYNoyfY0Kz6Op1xp3muZNQ Wk50XNeFqbzbcGd3riBEH9Pb/fEyT25SygpJdowefrDzMCNV5+IoSsPXpK6GmplBPtEw PAnSky6246LNq9WFakRi0BSUshIG0e5WTpamb3Ck5W6ytpnoC0zABzyd0q/myih/rdkW VaCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=Im+RfvZr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b005694ceaf704si7287236pgd.522.2023.09.17.19.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 19:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=Im+RfvZr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id C8B6181F3673; Sun, 17 Sep 2023 14:47:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239414AbjIQVfq (ORCPT + 28 others); Sun, 17 Sep 2023 17:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237676AbjIQVfX (ORCPT ); Sun, 17 Sep 2023 17:35:23 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A15C130 for ; Sun, 17 Sep 2023 14:35:17 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rph6V5bPFzFj; Sun, 17 Sep 2023 23:35:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1694986514; bh=QVca91oFtGzpLpEdY8ScokeQXsjkCHQgGWo6EomZVKI=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=Im+RfvZrI3P2GkPmU75TmPK1tLqo9jp7LTp1JtKAqIchr/0uPXgEtPXptK5mT2VIc 5JTK1CxP0FfUL2+KFN0aWZ/oXgBq9ygUM7yWR05JUXDpMOw4/X3HpXIkfkiGn/T0Ux OSql+jEQMaak/23UcD3i0ic7DyyM9DfiASF8VYSQyzAcALRwchCovuRVVKlIpjBRYY 7rOkTxtam8FpbpUu5JAG3/5K7wjL2VY0VFt1B+/o8QuAuM1v7EJxCuYrTWWhEMO2eE PF6kkgg796pGpsFaJIIXBzvCu0mcnfI1WufgIZaSl3g0lx5mczZUAhocuKFVzeHvLi VHrEehoEP1NOg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Sun, 17 Sep 2023 23:35:14 +0200 Message-Id: <811062614da5ec63ac9c975b77bdb6bf34720552.1694985959.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 1/2] regulator/core: regulator_register: set device->class earlier MIME-Version: 1.0 From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= To: Liam Girdwood , Mark Brown Cc: Vladimir Zapolskiy , Zeng Heng , linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 14:47:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777340899984678831 X-GMAIL-MSGID: 1777340899984678831 device_initialize() calls for the `device` struct be freed with `put_device()`. This requires a release() callback that is provided by the regulator_class. Fixes: d3c731564e09 ("regulator: plug of_node leak in regulator_register()'s error path") Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e1caaf207e..2f6ee5527cb0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5542,6 +5542,7 @@ regulator_register(struct device *dev, goto rinse; } device_initialize(&rdev->dev); + rdev->dev.class = ®ulator_class; spin_lock_init(&rdev->err_lock); /* @@ -5603,7 +5604,6 @@ 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)); From patchwork Sun Sep 17 21:35:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 141207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2328629vqi; Sun, 17 Sep 2023 15:41:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuWogiK+RNFkQR2WgUqvRinVUm2q9eNIaDNAtbxhAftmMgCaMdOIW9GUMKS37x8OSX22Wr X-Received: by 2002:a05:6a20:9148:b0:154:b4cb:2e61 with SMTP id x8-20020a056a20914800b00154b4cb2e61mr7179954pzc.60.1694990512226; Sun, 17 Sep 2023 15:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694990512; cv=none; d=google.com; s=arc-20160816; b=attxNNG++0XO3IJ6T0DJGY2jIkrCBBcKH9J7W40pLlepEsEVvW7i5xzOf9ifSJcCum B4IdhGVRAjOe/CAZEl4ENeU6WFobhOd4QMEBLmV4Oq0kDvTn1Ta53X2dXHw9BIuvJjF0 R/C7ptFpxxRa21pe6sfWiHOlMF2SmD6eNit0EzabtLpQIf62NFPTFUQZPzn4na9ubQNv qAKrI2tOTrneg0l+A+i+S9Pi5dNug59G7IkDfReMSdmqwbTBG3oi8NbO3nUerwyGWX1D u4EaDSHMb/tJDJDgpOjGdi/880W4HNSC0P1Abuy5Cy2etelIEIroN52f5jCuvnixDHEw 6E7Q== 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:references:in-reply-to:message-id:date :dkim-signature; bh=AkkLwN5s/fABvZ6JGIiUVvu2EguxMp5CtxxwUm/7GeE=; fh=q0TLCQSNPOFC/px7VHF1+KvjmoORcZngC8nAdCL3zfM=; b=J1dov89bPzE4iEuANbIBRUeE2bhsUTiqG14cKleUFwVjYTG2HNwgfME3qyn6O8KQJ5 PSVYMNCv4ljc1vpEEutB31bQ+vPTGAVr1+ucnlURxTA9goiVLuGcENOp4XCtQFoj3JDH tPJRTTZuW96IpBn5p/DT8btIFhV4C69ZC7EkZkZYcMMLNyIWAoRUegaVM1O1i4nqrSZj cge943zD4oR1C8+uuhHwAmKBRyvNN0MTks8nPhKSjH361egce2hofCWHu41e3DusXyKL aWvCXmUhrUOHGGJaWnixNk8ZVspe+9sWyr1y+wi7cZ6JSO5XlPKxfBD5Tk4cnjIOSAxM ZTXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=cFvaDmHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f22-20020a633816000000b0057807cdc6c0si5904577pga.710.2023.09.17.15.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=cFvaDmHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 2AE1881DF749; Sun, 17 Sep 2023 14:45:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238442AbjIQVfm (ORCPT + 28 others); Sun, 17 Sep 2023 17:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbjIQVfX (ORCPT ); Sun, 17 Sep 2023 17:35:23 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 790D5F1 for ; Sun, 17 Sep 2023 14:35:17 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rph6W0lPXzHx; Sun, 17 Sep 2023 23:35:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1694986515; bh=UIbXDMty5LFR94K/w6jaxWU7ApJpMH2RmAPQ/Wr0MaQ=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=cFvaDmHr4ZS3Nst/gI9ZxNLOkq1X7TIyx4n2b16SjWNCE5FoYzDUN49o2BMA5RvY7 M0cvNgGrvH8Q41rAp9LWnIlAq1cM1HiU1XbROidxh/J2Tc+oaFF4y2QDhDP0iAhzjf 0vIBUr+nvU9McUg5LxNcrp5PdBpuhBQwRfRtVgaUTzV+J5i8tIP6yhnU2KvZiRseHd RQhHQWOYCfWGyogNqeqv0HvjYYWloA+jAngELqGs8wFhVlKHkNO2sGDp8heAx/fp9Z DCoVtVhuq+aiXaWXYGlqHyrJdnh2xe1Ghe0G3pP/2iKQ6pO248GZ703l1+Rk4LQyUM eyIg7dxE7X/Wg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Sun, 17 Sep 2023 23:35:14 +0200 Message-Id: In-Reply-To: References: Subject: [PATCH 2/2] Revert "regulator: core: fix kobject release warning and memory leak in regulator_register()" MIME-Version: 1.0 From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Vladimir Zapolskiy , Zeng Heng X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 17 Sep 2023 14:45:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777326371630536965 X-GMAIL-MSGID: 1777326371630536965 This reverts commit 5f4b204b6b8153923d5be8002c5f7082985d153f. Since rdev->dev now has a release() callback, the proper way of freeing the initialized device can be restored. Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2f6ee5527cb0..0994caa5ad5c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5724,15 +5724,11 @@ regulator_register(struct device *dev, mutex_lock(®ulator_list_mutex); regulator_ena_gpio_free(rdev); mutex_unlock(®ulator_list_mutex); - put_device(&rdev->dev); - rdev = NULL; clean: if (dangling_of_gpiod) gpiod_put(config->ena_gpiod); - if (rdev && rdev->dev.of_node) - of_node_put(rdev->dev.of_node); - kfree(rdev); kfree(config); + put_device(&rdev->dev); rinse: if (dangling_cfg_gpiod) gpiod_put(cfg->ena_gpiod);