Message ID | ZLaZ03PzkbPNJQ3b@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1782957vqt; Tue, 18 Jul 2023 07:21:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsphm47uSLnH9SnjSBv+nPAFBNSLFaBigEniMYFU7MiJsj3tZ4h4ZLAE4pM+a4HTSTQGi3 X-Received: by 2002:a05:6a00:248f:b0:686:254c:9d4e with SMTP id c15-20020a056a00248f00b00686254c9d4emr1923913pfv.14.1689690091437; Tue, 18 Jul 2023 07:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689690091; cv=none; d=google.com; s=arc-20160816; b=BmrbHRxBQ1hMB7XR2z3zdeH4HtieJGp29Af30EmtmtIlaTMPOWjfPJWbE6l7kAI5AT ErM3UVGquRgOGQrN2zyQEJ8fRdp5Bg14mbhflxt6AUMEO6D1V+pWgzE2ekSJEAHKq+/g A1DiJ/SXe44566JA4DtBPtRC8eAfoZ+ev1d3vU6awvptjjb5MUbcrawNTMvMUKbxd/6u DYYN+RGGnzREMR5kpIlImgOF+UNvosJn/ASqQQK6caRqmPc2y17dFzkeKOl/NUobCuV9 7ggOM67eurM85bZbp6SV9yBmDd2p3RSw7ev8qtsoRR+Y/XGE3cp6NK7NU0XC6dvq9Kfv 0+mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=+WvS1xOd99/w6AlSC3wYtyuo/RUy6IsF9wjnm0AYfzU=; fh=he+Yx86cu3mN0DOFH5VYr11DEff1suEG6d8HBMg/nEI=; b=CUs/44+YiLGO8VbedOdlN9XjK4JhZKH8RmKGbfhvzHIcWphSaLcdsJPhWn4VS8kLzT /J4WLW+Ki0v2heCJiGkxzfrZq/K2XIGCfiZmEqfZG0+POmST7wMrE3F8eADtvwXeRNze Wc5AasOYWMGx/h7zgcjf/hKxFJn73qJvz5znE1O7qHkPa0pDQc2lyuI8tzCWc4SR7fnB Wz5PLRQcJYrMN6FVL9KUqiF6y7G5B3v4WMqqFVKaKhXvFKHceT7F/n+upBIcE5pOOJax vdQPgoGj9BgSUQMTQ5XTF/M/9LTW0KKKN4AHnoqfHldr88EtrWScAfhdfml/m1KHWWuN aygA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s133-20020a632c8b000000b005533750837csi1597600pgs.681.2023.07.18.07.21.17; Tue, 18 Jul 2023 07:21:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232983AbjGRNzz (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Tue, 18 Jul 2023 09:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232982AbjGRNzu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Jul 2023 09:55:50 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786E38F for <linux-kernel@vger.kernel.org>; Tue, 18 Jul 2023 06:55:48 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1qLlB2-0008Bb-2X; Tue, 18 Jul 2023 13:55:44 +0000 Date: Tue, 18 Jul 2023 14:55:31 +0100 From: Daniel Golle <daniel@makrotopia.org> To: Miquel Raynal <miquel.raynal@bootlin.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nvmem: core: clear sysfs attributes for each NVMEM device Message-ID: <ZLaZ03PzkbPNJQ3b@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771768477128000637 X-GMAIL-MSGID: 1771768477128000637 |
Series |
[1/2] nvmem: core: clear sysfs attributes for each NVMEM device
|
|
Commit Message
Daniel Golle
July 18, 2023, 1:55 p.m. UTC
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not
having any cells in order to make sure sysfs attributes of a previously
registered NVMEM device are not accidentally reused for a follow-up
device which doesn't have any cells.
Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/nvmem/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Tue, Jul 18, 2023 at 02:55:31PM +0100, Daniel Golle wrote: > Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not > having any cells in order to make sure sysfs attributes of a previously > registered NVMEM device are not accidentally reused for a follow-up > device which doesn't have any cells. > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") Where is this git commit id? I don't see it in Linus's tree. > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/nvmem/core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) Your patches were not threaded/attached to each other either, so our tools can't take them together. Can you fix that up and use 'git send-email' or other such tools to have this show up properly when you send a v2? thanks, greg k-h
On Tue, Jul 18, 2023 at 02:55:31PM +0100, Daniel Golle wrote: > Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not > having any cells in order to make sure sysfs attributes of a previously > registered NVMEM device are not accidentally reused for a follow-up > device which doesn't have any cells. Wait, attributes and devices should NEVER be reused, how is that happening here? And just setting the attribute field to NULL doesn't free or clean up anything, right? Did memory just leak with this? confused, greg k-h
HI Daniel, On 18/07/2023 14:55, Daniel Golle wrote: > Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not > having any cells in order to make sure sysfs attributes of a previously > registered NVMEM device are not accidentally reused for a follow-up > device which doesn't have any cells. > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") These patches are dropped out of nvmem next branch as it was breaking some existing users. --srini > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/nvmem/core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 6c04a9cf6919f..70e951088826d 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) > > mutex_lock(&nvmem_mutex); > > - if (list_empty(&nvmem->cells)) > + if (list_empty(&nvmem->cells)) { > + nvmem_cells_group.bin_attrs = NULL; > goto unlock_mutex; > - > + } > /* Allocate an array of attributes with a sentinel */ > ncells = list_count_nodes(&nvmem->cells); > cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
On Tue, Jul 18, 2023 at 03:55:56PM +0100, Srinivas Kandagatla wrote: > HI Daniel, > > On 18/07/2023 14:55, Daniel Golle wrote: > > Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not > > having any cells in order to make sure sysfs attributes of a previously > > registered NVMEM device are not accidentally reused for a follow-up > > device which doesn't have any cells. > > > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") > > These patches are dropped out of nvmem next branch as it was breaking some > existing users. Ok. I've encountered those commits in linux-next and can confirm that they were definitely also breaking things here, hence my patches at least partially fixing that. I agree that reverting them for now and reworking them seems to be the better option in this case, hence my patches won't be needed as such. > > > --srini > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > drivers/nvmem/core.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > > index 6c04a9cf6919f..70e951088826d 100644 > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) > > mutex_lock(&nvmem_mutex); > > - if (list_empty(&nvmem->cells)) > > + if (list_empty(&nvmem->cells)) { > > + nvmem_cells_group.bin_attrs = NULL; > > goto unlock_mutex; > > - > > + } > > /* Allocate an array of attributes with a sentinel */ > > ncells = list_count_nodes(&nvmem->cells); > > cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
Hi Daniel, daniel@makrotopia.org wrote on Tue, 18 Jul 2023 16:29:07 +0100: > On Tue, Jul 18, 2023 at 03:55:56PM +0100, Srinivas Kandagatla wrote: > > HI Daniel, > > > > On 18/07/2023 14:55, Daniel Golle wrote: > > > Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not > > > having any cells in order to make sure sysfs attributes of a previously > > > registered NVMEM device are not accidentally reused for a follow-up > > > device which doesn't have any cells. > > > > > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") > > > > These patches are dropped out of nvmem next branch as it was breaking some > > existing users. > > Ok. I've encountered those commits in linux-next and can confirm that > they were definitely also breaking things here, hence my patches at > least partially fixing that. > > I agree that reverting them for now and reworking them seems to be the > better option in this case, hence my patches won't be needed as such. Quite the opposite, on my setup I don't have any breakage but as you already fixed the cell name issue (also reported by Chen-yu), if you agree, I will include these fixes (or an improved version) in my next proposal. Thanks, Miquèl
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6c04a9cf6919f..70e951088826d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) mutex_lock(&nvmem_mutex); - if (list_empty(&nvmem->cells)) + if (list_empty(&nvmem->cells)) { + nvmem_cells_group.bin_attrs = NULL; goto unlock_mutex; - + } /* Allocate an array of attributes with a sentinel */ ncells = list_count_nodes(&nvmem->cells); cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,