diff options
author | Takashi Iwai <tiwai@suse.de> | 2024-02-22 12:15:07 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2024-02-23 10:57:31 +0100 |
commit | 5d04ad53e54c1513a90f44367d5712e984ba579b (patch) | |
tree | 8c5c2caa8a1e1716810ede0477b9c021324fc89f /sound/core/seq | |
parent | 1c4025d4ea0cabe05b2425889eed9298c713c771 (diff) |
ALSA: seq: virmidi: 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).
No functional changes, only code refactoring.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240222111509.28390-8-tiwai@suse.de
Diffstat (limited to 'sound/core/seq')
-rw-r--r-- | sound/core/seq/seq_virmidi.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 1678737f11be..35f93b43dd2a 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -363,26 +363,22 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) { int client; struct snd_seq_port_callback pcallbacks; - struct snd_seq_port_info *pinfo; + struct snd_seq_port_info *pinfo __free(kfree) = NULL; int err; if (rdev->client >= 0) return 0; pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL); - if (!pinfo) { - err = -ENOMEM; - goto __error; - } + if (!pinfo) + return -ENOMEM; client = snd_seq_create_kernel_client(rdev->card, rdev->device, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); - if (client < 0) { - err = client; - goto __error; - } + if (client < 0) + return client; rdev->client = client; /* create a port */ @@ -410,15 +406,11 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) if (err < 0) { snd_seq_delete_kernel_client(client); rdev->client = -1; - goto __error; + return err; } rdev->port = pinfo->addr.port; - err = 0; /* success */ - - __error: - kfree(pinfo); - return err; + return 0; /* success */ } |