Blob Blame History Raw
From 296a37fd029dd8a911396e3c28e0bbd5a2720a5d Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 13 Mar 2020 14:02:23 +0100
Subject: [PATCH] ALSA: pcm: Fix superfluous snprintf() usage
Git-commit: 296a37fd029dd8a911396e3c28e0bbd5a2720a5d
Patch-mainline: v5.7-rc1
References: bsc#1051510

show_pcm_class() returns obviously a short string that can't overflow
PAGE_SIZE.  And even if it were to overflow, using snprintf() there is
just wrong, as it doesn't return the correct size.
So simplify with sprintf() instead.

Link: https://lore.kernel.org/r/20200313130223.8908-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/core/pcm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -1081,7 +1081,7 @@ static ssize_t show_pcm_class(struct dev
 		str = "none";
 	else
 		str = strs[pcm->dev_class];
-        return snprintf(buf, PAGE_SIZE, "%s\n", str);
+	return sprintf(buf, "%s\n", str);
 }
 
 static DEVICE_ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);