Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6893994rwp; Tue, 18 Jul 2023 07:18:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFW+TCYcpl2N8ADw/WQa5SI+LQeXPJbyqQmUtl2iGSmg+X52GD2eqL5r2MxP7b3/x6wyFm4 X-Received: by 2002:a05:6a00:1a14:b0:666:eaaf:a2af with SMTP id g20-20020a056a001a1400b00666eaafa2afmr15293865pfv.14.1689689890090; Tue, 18 Jul 2023 07:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689689890; cv=none; d=google.com; s=arc-20160816; b=zHwlDCzCYy0PU7reumbjLfgiVG6tjLEnMBfczTQbfWIbByfgvX/ByUFvZ7YKBPFwmo AY9dQmO1Ug9Eh1+h+1jX2hEuwi5W6xMnnXPQAaRk7w+tz8nEyl87T4Xn/W3MdmbZeHWR xTz0qakQAQih69z56KIHuj/ps/enM9DowwRtEodFMatG5S+34lcI/CQj0CyoqxHxEZ3S fq7Wm1ddON6Gt/UbDjK9FkCRe2T4VTJEY6dtTJNhE1cjlIDN7DK2UVhRa32FhnDktQbS VAumdmDhTjrcEkQh3rUvSiPE4y02Md5zTGAQ7XDd6mrz89i7K9DPe0xKOh7+9vzoK92U knVA== 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=9rZu1ndO7BwoisEWFnA9Ij+utPV77y+0+ThAO9S+0R0=; fh=he+Yx86cu3mN0DOFH5VYr11DEff1suEG6d8HBMg/nEI=; b=nG9dqF3+AnUwyq8+PJGJRrWzeFMmEhKKgDbj8U86fTryLsddC/tk1fvtq+KIpcBQZr r6FVsO+N40QeJrSxrc3Ql7ypkuM1EtEuKpdCDj7Ljp5cUmPhmGo4bq0TRXg0jUkxfeHn SfQohaem/6LYRvb0fFlxtKt+/d/f8HOG9dKl5NoG/SMOfNS2mleqcKiJO9Wh1R5/sZwi TUscS83jYV1WQSKu2nzwod9wkgpUTVCwMzXzijaS4BC4A12vMbVENPva8NutGzSBNTU8 K+EwP2z0LDpUVSVmkCkThAwSQXRxhO72qb6ObFKNFQkegF19oWp3nQGn7H23iPavQXFz zp8w== 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 cn11-20020a056a00340b00b0068267c56811si1558990pfb.167.2023.07.18.07.17.57; Tue, 18 Jul 2023 07:18:10 -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 S232982AbjGRN4e (ORCPT + 99 others); Tue, 18 Jul 2023 09:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbjGRN4c (ORCPT ); Tue, 18 Jul 2023 09:56:32 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C4391712 for ; Tue, 18 Jul 2023 06:56:11 -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 1qLlBQ-0008CI-03; Tue, 18 Jul 2023 13:56:08 +0000 Date: Tue, 18 Jul 2023 14:55:57 +0100 From: Daniel Golle To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs 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 The device tree node names are not required to be unique. Append the offset to the name to make cell nodes with identical names become accessible via sysfs and avoid kernel stackdump caused by sysfs: cannot create duplicate filename '...' Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") Signed-off-by: Daniel Golle --- drivers/nvmem/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 70e951088826d..90fe9dc30f8ba 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -480,7 +480,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) /* Initialize each attribute to take the name and size of the cell */ list_for_each_entry(entry, &nvmem->cells, node) { sysfs_bin_attr_init(&attrs[i]); - attrs[i].attr.name = devm_kstrdup(&nvmem->dev, entry->name, GFP_KERNEL); + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, + "%s@%d", entry->name, + entry->offset); attrs[i].attr.mode = 0444; attrs[i].size = entry->bytes; attrs[i].read = &nvmem_cell_attr_read; -- 2.41.0