diff options
author | Takashi Iwai <tiwai@suse.de> | 2024-02-22 12:15:01 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2024-02-23 10:57:30 +0100 |
commit | ae921398486419c6284d70bd8332eb7edbdb4f70 (patch) | |
tree | 58d3cfe9a8d328cf36aef57f375fe1c79306e77c /sound/core/pcm.c | |
parent | ec89fc1b71766c9e7a122f8ba7a21933fe6a95b4 (diff) |
ALSA: pcm: Use automatic cleanup of kfree()
There are common patterns where a temporary buffer is allocated and
freed at the exit, and those can be simplified with the recent cleanup
mechanism via __free(kfree).
A caveat is that some allocations are memdup_user() and they return an
error pointer instead of NULL. Those need special cares and the value
has to be cleared with no_free_ptr() at the allocation error path.
Other than that, the conversions are straightforward.
No functional changes, only code refactoring.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240222111509.28390-2-tiwai@suse.de
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r-- | sound/core/pcm.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index d9b338088d10..87d27fbdfe5c 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -342,7 +342,7 @@ static const char *snd_pcm_oss_format_name(int format) static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, struct snd_info_buffer *buffer) { - struct snd_pcm_info *info; + struct snd_pcm_info *info __free(kfree) = NULL; int err; if (! substream) @@ -355,7 +355,6 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, err = snd_pcm_info(substream, info); if (err < 0) { snd_iprintf(buffer, "error %d\n", err); - kfree(info); return; } snd_iprintf(buffer, "card: %d\n", info->card); @@ -369,7 +368,6 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, snd_iprintf(buffer, "subclass: %d\n", info->dev_subclass); snd_iprintf(buffer, "subdevices_count: %d\n", info->subdevices_count); snd_iprintf(buffer, "subdevices_avail: %d\n", info->subdevices_avail); - kfree(info); } static void snd_pcm_stream_proc_info_read(struct snd_info_entry *entry, |