ALSA: hda: Use scnprintf() for string truncation

snd_hdac_codec_modalias() truncates the string to the given size and
returns its size, but it returned a wrong size from snprintf().
snprintf() returns the would-be-output size, not the actual size.
Use scnprintf() instead to return the correct size.

Link: https://lore.kernel.org/r/20200313130241.8970-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2020-03-13 14:02:41 +01:00
parent 296a37fd02
commit 0a7efa14e6
1 changed files with 1 additions and 1 deletions

View File

@ -204,7 +204,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_set_chip_name);
*/
int snd_hdac_codec_modalias(struct hdac_device *codec, char *buf, size_t size)
{
return snprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n",
return scnprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n",
codec->vendor_id, codec->revision_id, codec->type);
}
EXPORT_SYMBOL_GPL(snd_hdac_codec_modalias);