Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6905933rwp; Tue, 18 Jul 2023 07:27:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFySTb7TJkbzqnKen3NRJVBkT+JshT+JLlJ7Q8eyPX+BIJVUNQt+v2hXjIY6Boqxol748+h X-Received: by 2002:a05:6512:46d:b0:4fb:90f7:6769 with SMTP id x13-20020a056512046d00b004fb90f76769mr9154455lfd.21.1689690434242; Tue, 18 Jul 2023 07:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689690434; cv=none; d=google.com; s=arc-20160816; b=lpoNaaMXfqHbSDM0kxmn/2isLXIwoBQjbsGGC+aQWKXmy0+t1+karu/v1kCSAt+VK6 tVXzfIpmRlwLbktzkZe1upqqEdsQkXy4eShd3rM+0/YLs03yQu8ngCcbtGbL/zbRNbIV 6SYxRV+2lgNQPurPtWwXOlDQjQqY7FPvrJmP9tcG9koVtnLP7QqeHKATfikAz2I95UZ/ FqCxWSY53yPXqLQni5WfdG2rGQ4bbz12TLw76xdD8JaTvcSfR/+vlufDaZsJhJEfCGRQ iHGrzAGp4Jz16Nxotv4ItfS6nP2wcjtmta++VpAAbrYV83rGkO1VE7DxalXeCf7fkI7P DpAg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a056402205600b0051ddfc275b8si1201889edb.421.2023.07.18.07.26.50; Tue, 18 Jul 2023 07:27:14 -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 S232981AbjGRNzz (ORCPT + 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 ); 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 ; 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 ) id 1qLlB2-0008Bb-2X; Tue, 18 Jul 2023 13:55:44 +0000 Date: Tue, 18 Jul 2023 14:55:31 +0100 From: Daniel Golle To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nvmem: core: clear sysfs attributes for each NVMEM device Message-ID: 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.41.0