From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9736EB64DC for ; Tue, 18 Jul 2023 13:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbjGRNz5 (ORCPT ); Tue, 18 Jul 2023 09:55:57 -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 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