From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4B014F5E0; Wed, 20 May 2026 18:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300032; cv=none; b=hlPD66Y3OiL3F/+wFK8drvb1n8sFd7Ev0KToUi8kN6LMKhfhBTIXWQRPb1EBAeyf0zJSpU6cNt8NJj/5xs1add9bnLmAbs84gIyWcK3adcNM6Vo50A3h9Pg4awtD2NMF/nrHVwaf+9JJ8VA93pXWRO1bpWaw4Rkb6IBYzC2IOu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300032; c=relaxed/simple; bh=9+MQjh0laZe8pD/h0TKW9JOSfbnmyxLeQBxmTNUp0qI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ygjk6ogAbSXS08u8Mx+ZBHTA+K9jPWzLf5JGdUyvDs6mZ2xqrPYp6jstUo+9ka3v9BPP/n+McP81gXvAe012QvhytIDcuqM4bAJBRsbjYVjG6XSirxqoierGqpVvRuUcOeBPh/KqPE5j8CuKScKV6YxnPKqjDtdT3b1N3kggpFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TcPfC9aN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TcPfC9aN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45E101F000E9; Wed, 20 May 2026 18:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300031; bh=4nj1tSrJlOHsmRqc7lGN7wCW9oS/iVezEmEoYKqA5nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TcPfC9aNhwPLCqc5SkypCTvNzlhz5Iqfde85ynxNix0hkLLdwu6VkPVU8UrNl0cLx yYMtrYIkgcnlzUMoMqljRNzGZFb7xUCv0Mhdj1e3W6AJHpSpQri/OGi9TvXa/707OE O48ZjTjcudbdLfnydEOAbqMn/fNHRn8w4HBn8HWg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, yangshiguang , Gui-Dong Han , Sasha Levin Subject: [PATCH 6.12 021/666] soundwire: debugfs: initialize firmware_file to empty string Date: Wed, 20 May 2026 18:13:52 +0200 Message-ID: <20260520162111.690467587@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gui-Dong Han [ Upstream commit 7215e4552f31e53595eae56a834f7e286beecccc ] Passing NULL to debugfs_create_str() causes a NULL pointer dereference, and creating debugfs nodes with NULL string pointers is no longer permitted. Additionally, firmware_file is a global pointer. Previously, adding every new slave blindly overwrote it with NULL. Fix these issues by initializing firmware_file to an allocated empty string once in the subsystem init path (sdw_debugfs_init), and freeing it in the exit path. Existing driver code handles empty strings correctly. Fixes: fe46d2a4301d ("soundwire: debugfs: add interface to read/write commands") Reported-by: yangshiguang Closes: https://lore.kernel.org/lkml/17647e4c.d461.19b46144a4e.Coremail.yangshiguang1011@163.com/ Signed-off-by: Gui-Dong Han Link: https://patch.msgid.link/20260323085930.88894-4-hanguidong02@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/soundwire/debugfs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c index c30f571934ee2..93c93a128fb23 100644 --- a/drivers/soundwire/debugfs.c +++ b/drivers/soundwire/debugfs.c @@ -295,8 +295,8 @@ void sdw_slave_debugfs_init(struct sdw_slave *slave) debugfs_create_file("go", 0200, d, slave, &cmd_go_fops); debugfs_create_file("read_buffer", 0400, d, slave, &read_buffer_fops); - firmware_file = NULL; - debugfs_create_str("firmware_file", 0200, d, &firmware_file); + if (firmware_file) + debugfs_create_str("firmware_file", 0200, d, &firmware_file); slave->debugfs = d; } @@ -308,10 +308,15 @@ void sdw_slave_debugfs_exit(struct sdw_slave *slave) void sdw_debugfs_init(void) { + if (!firmware_file) + firmware_file = kstrdup("", GFP_KERNEL); + sdw_debugfs_root = debugfs_create_dir("soundwire", NULL); } void sdw_debugfs_exit(void) { debugfs_remove_recursive(sdw_debugfs_root); + kfree(firmware_file); + firmware_file = NULL; } -- 2.53.0