mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergio Perez Gonzalez <sperezglz@gmail.com>
To: vkoul@kernel.org, yung-chuan.liao@linux.intel.com
Cc: Sergio Perez Gonzalez <sperezglz@gmail.com>,
	pierre-louis.bossart@linux.dev, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] soundwire: sysfs_emit() expects a buffer of size PAGE_SIZE
Date: Wed, 23 Jul 2025 17:09:25 -0600	[thread overview]
Message-ID: <20250723230927.109534-1-sperezglz@gmail.com> (raw)

In read_buffer_show(), allocate sufficient memory to pass on to
sysfs_emit(), which expects a buffer of size PAGE_SIZE.

Link: https://scan7.scan.coverity.com/#/project-view/53936/11354?selectedIssue=1648019
Fixes: 35323d8ab811 ("soundwire: replace scnprintf() with sysfs_emit() for sysfs consistency")
Signed-off-by: Sergio Perez Gonzalez <sperezglz@gmail.com>
---
 drivers/soundwire/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c
index 825f7abbad32..08fb1e29026e 100644
--- a/drivers/soundwire/debugfs.c
+++ b/drivers/soundwire/debugfs.c
@@ -306,12 +306,12 @@ static int cmd_go(void *data, u64 value)
 DEFINE_DEBUGFS_ATTRIBUTE(cmd_go_fops, NULL,
 			 cmd_go, "%llu\n");
 
-#define MAX_LINE_LEN 128
-
 static int read_buffer_show(struct seq_file *s_file, void *data)
 {
-	char buf[MAX_LINE_LEN];
 	int i;
+	char *buf __free(kfree) = kzalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
 
 	if (num_bytes == 0 || num_bytes > MAX_CMD_BYTES)
 		return -EINVAL;
-- 
2.43.0


             reply	other threads:[~2025-07-23 23:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 23:09 Sergio Perez Gonzalez [this message]
2025-07-24  7:19 ` Takashi Iwai
2025-07-24  9:52   ` Vinod Koul
2025-07-25 18:22     ` Sergio Pérez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250723230927.109534-1-sperezglz@gmail.com \
    --to=sperezglz@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®