From nobody Fri Apr 3 20:53:02 2026 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 317FA38228F for ; Mon, 23 Mar 2026 09:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256459; cv=none; b=ke6G6Pv4FpDsJyJp8sy7bX6nxUnMbWClKjY24NZc32QSH7PBa/vHw2Rv31ppyicl/WP2wUCGUxJUk/8TfNfmnf2QglIjqhi/Y9LIA0ckrv5ZNyEg+A/esbQc2iTJxe//aTq9EfZVSU1NPlDrUcab4UXMfC007Q/Zhb8+0/Y5RW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256459; c=relaxed/simple; bh=Cl5yPFxk//8Ej78GNhA/VX9CqrDUv6u1CQCqFHTaYvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I7W4aeGLdLAEGnm9BcgDSW/UgZO2CS5IFo61VhchS9crAOx1XcIfdufKacoVmvjnznWg+5hMf52HI/6I06fUw0RKb31dpzFCNHYSP58NOUrDGS5kB2sDPCufj7rCidMcR22qNH7cOd3hcniC12ePOx9muOqZ9fTMdF1gpItWjng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NaOKfm+e; arc=none smtp.client-ip=74.125.82.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NaOKfm+e" Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-12732e6a123so5214078c88.1 for ; Mon, 23 Mar 2026 02:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774256457; x=1774861257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u0lLd0QkDOzCbjNYQorhBBOJpZyLtToijPDM8Z8Tmtc=; b=NaOKfm+eKRX7z/WY8Tcwb9pewt5lx9HRDQ0vTOSYaGxc64YykdEhIO6fdE5UlUUMwh YpUVeoHO5zwXKFs7m5hzYgXGyOyA6B89ouCcONKj69ViTZeq/TD7K8k1qKuVzqdLp/Cu gWyKbQto8r03tcG+N2W7Zc5ht8oJ+b7gQs14eeqZNw4gbCwucieAX8ajBuJskoxmYb1J 90V569/3FTkau1ljRMENCvmm4EfiNjnS07XIqOw3MM+bKR8NqAqPzojDF05Yrbnbl6bq hM8END4ViQfzSNIPtZtu+FX3wKJt7A46NOJQfnDJEYuNQVzk7SQ6VvAq+DPloANDDPaQ 6HIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774256457; x=1774861257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u0lLd0QkDOzCbjNYQorhBBOJpZyLtToijPDM8Z8Tmtc=; b=ACRZ6Z+E+6bk0NeX1FI/+X5DmUIW9jmO5uC4KpohmgdbZQrpu2CCYAi8VDmdr8Boqe T9m+0MgNI4A46cTXODzOAS2rXTi2mJYbA2Lix08ZvtV0MO0F66MffnQgjCH6WKg8JhKx jT8l2dLZJhlE8QUJechxmTRhMWtMG5yer+XPnpoVeN7piyNzxwhNxrSn1RZb5sPDTgvB yiCBddrlmEb1P02ZCmcmhhW65+18wDuk0ufCXhoGS6RuNTfLgGgF/WpczFDAYNFOuUg1 lJ+V7Rpu/upi9F77y5V4oHvjKVGHZ0pnj9sSgbkCZXjVBnWrcq5cjpQ8QtGOvcU0nSn/ yuhQ== X-Forwarded-Encrypted: i=1; AJvYcCUCj/vQxEB5+RoaYtq9R67+ZvqZ6FRt/uxRBo97i6WRg0g41T6zUyIMunvXW42RgG0hdQzu6oPRPA/YF4I=@vger.kernel.org X-Gm-Message-State: AOJu0YwIUvCi0Nan2yrBDajG3jYUn0IwGUegC0IJSaKk4930bjM5D0q4 8okyHskQ5fBoSbtaFgdnZxzqP4MXRtnvLly3ptV2kTN/MIEW1WK2zczH X-Gm-Gg: ATEYQzz8gsg3qotPbmtKlDqYRiyCZI6LdZQDSocE2DHU0kQtstGAbYxQrm0/IVNZgfy ytgRXNbBKpiJqNkE1mXAAZxXFW45UDSYZI4LYsgLyjlkmXZlyEtHyQ5klVoh41BV/CePKOia3Xp MID2v27Ha9jGzmUPkxcDZv8iDkLhwVqt0u4ygMUuGhDatbyIcoHHJYOUXr1z0iu3ShAM7w3EAAZ I6+qENwUjwzDcJHnewiH1bbFRweo5nMmdLbGRY8ysGyq0m2fwJAkZgr0CcLVABiWLfmwqUPXU5u LEZDpej6gEwUdGRFMpDJIxSfKciuNlUR9tqrT5xP2bKqsQ70pXej9ZiBeG/9tW5RzuQ7bdEqKdq baqSVr/ou8A0+59q08gUaOdUL4qNcgMLw3TxPjcT1n8CrNe4USADOr0DWvG0gIoLk3eIP/iYxnm N+tC9PkW1kHG0/ck4mdwxgSJGY3pkzK6mKESQ5kNnchoawzAr8TJwhAf37ZgFL8qHiOMrNr2IjT xgawhbsN7UZ9uKHKyN79oIROUOAkmQfJy7tzwK6xn4RKQJR92NQNXWidIUAbMSfpmg= X-Received: by 2002:a05:7022:628c:b0:128:cf5c:5352 with SMTP id a92af1059eb24-12a7266f502mr5323136c88.4.1774256457159; Mon, 23 Mar 2026 02:00:57 -0700 (PDT) Received: from 2045L.localdomain (90.sub-75-221-98.myvzw.com. [75.221.98.90]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12a734bb33fsm8620227c88.9.2026.03.23.02.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:00:56 -0700 (PDT) From: Gui-Dong Han To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev Cc: peterz@infradead.org, cristian.marussi@arm.com, sudeep.holla@kernel.org, linux-sound@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han , yangshiguang Subject: [PATCH v2 1/3] debugfs: check for NULL pointer in debugfs_create_str() Date: Mon, 23 Mar 2026 16:58:44 +0800 Message-ID: <20260323085930.88894-2-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323085930.88894-1-hanguidong02@gmail.com> References: <20260323085930.88894-1-hanguidong02@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Passing a NULL pointer to debugfs_create_str() leads to a NULL pointer dereference when the debugfs file is read. Following upstream discussions, forbid the creation of debugfs string files with NULL pointers. Add a WARN_ON() to expose offending callers and return early. Fixes: 9af0440ec86e ("debugfs: Implement debugfs_create_str()") Reported-by: yangshiguang Closes: https://lore.kernel.org/lkml/2025122221-gag-malt-75ba@gregkh/ Suggested-by: Greg Kroah-Hartman Signed-off-by: Gui-Dong Han --- v2: * No changes. --- fs/debugfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 3376ab6a519d..a941d73251b0 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -1127,7 +1127,7 @@ static const struct file_operations fops_str_wo =3D { * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. * @value: a pointer to the variable that the file should read to and write - * from. + * from. This pointer and the string it points to must not be %NUL= L. * * This function creates a file in debugfs with the given name that * contains the value of the variable @value. If the @mode variable is so @@ -1136,6 +1136,9 @@ static const struct file_operations fops_str_wo =3D { void debugfs_create_str(const char *name, umode_t mode, struct dentry *parent, char **value) { + if (WARN_ON(!value || !*value)) + return; + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_str, &fops_str_ro, &fops_str_wo); } --=20 2.43.0 From nobody Fri Apr 3 20:53:02 2026 Received: from mail-dl1-f44.google.com (mail-dl1-f44.google.com [74.125.82.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA0033845D9 for ; Mon, 23 Mar 2026 09:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256541; cv=none; b=g+gikhCvOZJ5KeMQ/xSVB2QViI4gGf7lvyQ/g7IjKOmdXujXUtIs+fUefg3RSQMqmmwiwdp4I29HvpLVRoZ8mDVdkxTGQIL3vvuTN0hnxt6/97UtJMTz6JaD8pnFnWkdbdRT+oXW1pCUJZpa9Nu8RJ1aBX9db9Vehic7KtfhSVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256541; c=relaxed/simple; bh=gq1YDhINbE7C0TGxm6aIJ7yhmIyt+boZmjgdjZwN9lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G0W808/5I5ccmr7yW64pQrCDCiVXfhjzbbTm60c5XDKQd8xuhpYb/a8I6pFAQrzLgdTGFpfbVO5cseolI8+incNGpNE0AsmuFYQeb9AL4N40aB5D1YXARmteAvXu3v3WvEA3DCo9JqnUTwp/2oYKcQbw8qyGW/zagBpOz8CNWaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O1KxNi6N; arc=none smtp.client-ip=74.125.82.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O1KxNi6N" Received: by mail-dl1-f44.google.com with SMTP id a92af1059eb24-12732e6a123so5216659c88.1 for ; Mon, 23 Mar 2026 02:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774256540; x=1774861340; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+xrYmE2Pi3T7YtcUDRXPeAvmyynPywp5N49YDr8P630=; b=O1KxNi6NcDWwXyuuC+K00379yFd7596tsyRp96TcHOHuBORw63dMbKyfJEveAp9vY5 vHJOY5vVi9LVq/dYyd09VDDniJhOECMk3tY0vLmPmrkVAJucoXa/42JuRmN/I+WilplA vhMNIvzjPF0uRdCGTWLxA1TBrHocCuosrhXnnxiD2G83rLwf1kFTj9S4pGHQHYBa/3p8 jQvBRSV6McGQtkDIIQdyBspfzcLrmNCvAkxROyovCeG7/DGezoDUXXWokVKej9KQbeGO 6TG95xw9aQ2XWMCLSSdshbzXRtyZMMvKmLC5gK1I3omf44r6YzGYtQQrlz76cbD9aaZK lEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774256540; x=1774861340; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+xrYmE2Pi3T7YtcUDRXPeAvmyynPywp5N49YDr8P630=; b=cEmK9vbTU20zsUZDAmO/C7MYGqRphRAnYobE5vTTfI0RYLT68eRCHKSOdutn33w1TE 9/qot+2vBF2LIsiMAZl2vaOBxbhbifPo6/jo/r3V2hK7v2ayBCmd+HV6ebaEiUnPRX8T Qb1ut06921zavBIPIQCoEh11xCgxsbe0T4q2ANrfcQkkM5HT0B5WoJiymbNRHXX26py2 pJKbFbCoGHYJqpjM67RzHTFZcCiwVDP6Budl4cfs6iiLJBrDjEHR6a0lwL+4RlDgzkxL /S4TBwUnSMmAn7lbF7E0nAxuqu/CqawZZp7eC2Os7RGT6q1Ym9RH3wxsfY+50JSYk15z lgHw== X-Forwarded-Encrypted: i=1; AJvYcCXQK+OrSXBVXfbN7m1JJA3IsB6ISsII0xybFbmdvo8fq6/e+QHMMtoWPtX8xXsnjp1SVoAu8lP/246XkpY=@vger.kernel.org X-Gm-Message-State: AOJu0YwVyyrpu4YK35yUg8a48zU7Ksr3W/nRemxLpnXjQzr17CF3diKc 8PDh8O/Yx7OZTorRDvpvhBfIJEN94zpYnZuI4xGcdOioX+T1INELfTaj X-Gm-Gg: ATEYQzxUEav3SsLKxZ2kG296/HY/NjIDkEi/jXYgvBNUUNiTKWhIpi9iCyRWXrxV+SC RxrtG8VZFdkPSBj9Bew/aQon9fTSDOHXde1J8I8S5v69L+jmvDnlO3YE4pKHkXBDgd/AcsdJ9tb H0HAIrVl7xxU7gqQC3n8H+7tHH7dKoJ3nqUJKAfcatnLnWE4HKKbhUDuwN9jotB/9gTxNw+kl89 urcItNFqrf7Df9CTwNDBMNTNhfj02XwsdzMxTay791zj2lXAMAIkXenEFPV4eVSqhX5+m7X+yW+ 5mtt5PHPNwXJSFR0UD+ozYAOXZ/ecQbqAVaPlzSTSVNfuKLXBNoX9xPTP0DS+7XobAEJAKoKL0T j+L6rZOW4V9WhokzsvBAynf9wB0Dx6/hYbxeF1PVaTG0mPcVkuuMrfsnhYVJ9AhBdradOCs5KTv DUf79g0/vDjr5BW6I6Rqh6j8kHCxrk40rng7Z7feZzV2yJQhIM7oTz1uj6uwBztjCZrKyt8RjMs cHu9iPpy9pxMWMM3IU2KizQ1b4RQ5QrLXs9UTB4/SFWtsK8bw1o2Aj+aZvAmn8t3KewjnCgxqRo Ww== X-Received: by 2002:a05:7022:68a4:b0:124:9e46:82d6 with SMTP id a92af1059eb24-12a726d995bmr5281257c88.25.1774256539707; Mon, 23 Mar 2026 02:02:19 -0700 (PDT) Received: from 2045L.localdomain (90.sub-75-221-98.myvzw.com. [75.221.98.90]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12a734bb33fsm8620227c88.9.2026.03.23.02.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:02:19 -0700 (PDT) From: Gui-Dong Han To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev Cc: peterz@infradead.org, cristian.marussi@arm.com, sudeep.holla@kernel.org, linux-sound@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han Subject: [PATCH v2 2/3] debugfs: fix placement of EXPORT_SYMBOL_GPL for debugfs_create_str() Date: Mon, 23 Mar 2026 16:58:45 +0800 Message-ID: <20260323085930.88894-3-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323085930.88894-1-hanguidong02@gmail.com> References: <20260323085930.88894-1-hanguidong02@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The EXPORT_SYMBOL_GPL() for debugfs_create_str was placed incorrectly away from the function definition. Move it immediately below the debugfs_create_str() function where it belongs. Fixes: d60b59b96795 ("debugfs: Export debugfs_create_str symbol") Signed-off-by: Gui-Dong Han --- v2: * No changes. --- fs/debugfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index a941d73251b0..edd6aafbfbaa 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -1047,7 +1047,6 @@ ssize_t debugfs_read_file_str(struct file *file, char= __user *user_buf, =20 return ret; } -EXPORT_SYMBOL_GPL(debugfs_create_str); =20 static ssize_t debugfs_write_file_str(struct file *file, const char __user= *user_buf, size_t count, loff_t *ppos) @@ -1142,6 +1141,7 @@ void debugfs_create_str(const char *name, umode_t mod= e, debugfs_create_mode_unsafe(name, mode, parent, value, &fops_str, &fops_str_ro, &fops_str_wo); } +EXPORT_SYMBOL_GPL(debugfs_create_str); =20 static ssize_t read_file_blob(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) --=20 2.43.0 From nobody Fri Apr 3 20:53:02 2026 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DA0A35F17D for ; Mon, 23 Mar 2026 09:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256553; cv=none; b=HJ+iZ1mU/VgUIA4oNjar+pedHNEJk+iHz5+8oWv4idqC41drz79y0I/RhPMu0IEieP3ehZQQZa2PNUlvBMgBhKe5F3DinutoCzL+WT9QRPzkgHJ+Zt8VB0csSZn9kiuZ62DCVcTi/mS48L/UhqQTfr9CPdqFz/oomHUCw7W3gWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774256553; c=relaxed/simple; bh=cDfCpC2k5COsvd3GHRWIpuxPdl/asKWV7zeOf4SM5dg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sKLd6HGbginCqmZbhb7YjSDP1L0ElrCUAT0NFYx8r9WlyQdmvwShWUpKzFgGBmHObfo9hfxUZkEId5RwS1NQxuKYSw+3GVhjG3dtrWnd969w4Ea3q2ao2oqi3DFIMr2SDC5VkDf6Gx/1WB3UB+xcfLt+YBkrVjupWkQYZ474/v4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uyk7JJTm; arc=none smtp.client-ip=74.125.82.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uyk7JJTm" Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1273349c56bso3383025c88.0 for ; Mon, 23 Mar 2026 02:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774256550; x=1774861350; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tg0E61uEdPAy3sHgDaZndNka+4Nyveqsr6678EIZbOY=; b=Uyk7JJTmXtrOOi9pV42OguJldt83APHKG0w/Up3IdwACALVp66ir3E6eYKEkpHYnij BPTpajZ2efyBtH5VnFUNyhvnuIRhDPqQBIUnUXE1182a7TIfzyD67kZcEOvVgTboOOUk jD6Yn7dFB5pdBgFGYfeVI4319nA4s8yCNSayHg5v1GuCtwCs/d2yp3FyJU5uQwiYOeXv goLXjrGadaZEt0th3WgitbgTYsnD+r/E3++JC2Xug9Hu3nVr+fuEdG1rgkxlmZOj9zqw 8B3yVxlAikY+2bzC6m4Q8uGYVhWMz+qxh019FIFQSoGtm2r7WGM1vFUFmUx2cmuhZOHf kPAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774256550; x=1774861350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tg0E61uEdPAy3sHgDaZndNka+4Nyveqsr6678EIZbOY=; b=bUvvlUwYsC0aKQc5hS7lllNeX65IhSRnyYUlgrL1IGH+1xQ1LxHaQml1rD3z+5JaHa YtAdevqxMTX3SlokMzEqy/Jdq1qr1YANejF/kEd6lffhgIvnOXqdOScRzAy0u4QXwI9n Ct6BqxgF74CpqEHCyT+BGqJVeDAzt15H/WbuztC3E4g8/qo8L4idln8bkDhBWZb5fxBF P3xsxE7+YVgYy0sC5+AJERU0EdEabkbRpHJrtus/kFIEkZsErCJuu+0eO/pcLoZZl+XV YQ/ISzsaPhSjwFIX5Fz2I1FntirocdoPMnA1EEYjKcZ4n6t4nR4qlOSP1GmBX2VVAU3t 6Kgw== X-Forwarded-Encrypted: i=1; AJvYcCVidMFqtoVLAwhddUoZbqxhJ+LAQAtFD3bqO4IyryFH/RweAHHtbQbjkguzrudbdPhm0KRROzaqBg8xk3I=@vger.kernel.org X-Gm-Message-State: AOJu0YzDMS3cLHIHJDO2OuCtUNCmhisJfQRfQ0FlSxAhtSva/ppM4GDC yTW1WtqgA170JqmXKTzgzDbBtX+IRONvLO+zBDjKvOMVYnYaW7GHdkFs X-Gm-Gg: ATEYQzw76z6IYV2ONwXVjXDVBD83q1juEf8XdRuNgRGCMCDQLhm5WFjKSJvurUUs+Ha Sb8Is77diOqppJXg0ycr06XtHBTHaPosQf+jtakHEUNpSLItHV0oQ4IVpKFULmNABf7J3vWvilb aQPdvBHHQwJZEvIs7YgjSJ5JMmotkSu6aLPtFpsVuAShOsMK5ur804W8t1kM6mNE0sitYUa433F Xn5HCTJQikGEAR1gPESosn8CjiHLv8XiUWKnpw0qUpzINWaw7kL29NV81iYCL5DrjanUcRyRvwU 39HTQAj9HgsGQ0aLZSuwJ2KKEvWRY1h6XIOtZ1B1XRs/v99laHSdUSFui5VHzs12qJ27cmf1/6r jL0Z7VlvoEDkAzUSZVJAFC1XVxBWIPwwEKkS0hUDOVUnTEl4si6+w1jnj7FsbPOtXDjlTzM2YcU ISrTokAYi4bBt8ZxY/mWA10FGEZ/cE94N8iRDYjxk3JTqJkAWd28MPWMv7X5EbBq1gFVodGdJ6p l5eKAWfm9PPV7FXHaOel9qxPM3tsGV9pOOHb8hFrf1CFd2sAZvlUD9Qd53FaF+TElQ= X-Received: by 2002:a05:7022:f68b:b0:128:d4db:447a with SMTP id a92af1059eb24-12a726cd01bmr4665776c88.29.1774256549584; Mon, 23 Mar 2026 02:02:29 -0700 (PDT) Received: from 2045L.localdomain (90.sub-75-221-98.myvzw.com. [75.221.98.90]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12a734bb33fsm8620227c88.9.2026.03.23.02.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:02:29 -0700 (PDT) From: Gui-Dong Han To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev Cc: peterz@infradead.org, cristian.marussi@arm.com, sudeep.holla@kernel.org, linux-sound@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han , yangshiguang Subject: [PATCH v2 3/3] soundwire: debugfs: initialize firmware_file to empty string Date: Mon, 23 Mar 2026 16:58:46 +0800 Message-ID: <20260323085930.88894-4-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323085930.88894-1-hanguidong02@gmail.com> References: <20260323085930.88894-1-hanguidong02@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 comma= nds") Reported-by: yangshiguang Closes: https://lore.kernel.org/lkml/17647e4c.d461.19b46144a4e.Coremail.yan= gshiguang1011@163.com/ Signed-off-by: Gui-Dong Han --- @SoundWire maintainers: Reviewed-by and Acked-by tags are welcome. Based on my testing, reading a string node created with a NULL pointer causes a crash, and writing to it returns -EINVAL. This completely breaks the interface, making me highly suspect this code has never actually been used. Additionally, sharing the global firmware_file pointer is inherently racy. I will investigate fixing or removing it entirely in a follow-up patch, as it falls outside the scope of this series. v2: * Replace devm_kstrdup() with kstrdup() to fix allocation/free mismatch with debugfs. * Move initialization to sdw_debugfs_init() to correctly handle the global pointer and avoid overwriting during slave probe. --- 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 ccc9670ef77c..2905ec19b838 100644 --- a/drivers/soundwire/debugfs.c +++ b/drivers/soundwire/debugfs.c @@ -358,8 +358,8 @@ void sdw_slave_debugfs_init(struct sdw_slave *slave) debugfs_create_file("go", 0200, d, slave, &cmd_go_fops); =20 debugfs_create_file("read_buffer", 0400, d, slave, &read_buffer_fops); - firmware_file =3D NULL; - debugfs_create_str("firmware_file", 0200, d, &firmware_file); + if (firmware_file) + debugfs_create_str("firmware_file", 0200, d, &firmware_file); =20 slave->debugfs =3D d; } @@ -371,10 +371,15 @@ void sdw_slave_debugfs_exit(struct sdw_slave *slave) =20 void sdw_debugfs_init(void) { + if (!firmware_file) + firmware_file =3D kstrdup("", GFP_KERNEL); + sdw_debugfs_root =3D debugfs_create_dir("soundwire", NULL); } =20 void sdw_debugfs_exit(void) { debugfs_remove_recursive(sdw_debugfs_root); + kfree(firmware_file); + firmware_file =3D NULL; } --=20 2.43.0