mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
ALSA: timer: 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-5-tiwai@suse.de
This commit is contained in:
parent
9b02221422
commit
ed96f6394e
|
|
@ -1645,7 +1645,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
|
||||||
static int snd_timer_user_ginfo(struct file *file,
|
static int snd_timer_user_ginfo(struct file *file,
|
||||||
struct snd_timer_ginfo __user *_ginfo)
|
struct snd_timer_ginfo __user *_ginfo)
|
||||||
{
|
{
|
||||||
struct snd_timer_ginfo *ginfo;
|
struct snd_timer_ginfo *ginfo __free(kfree) = NULL;
|
||||||
struct snd_timer_id tid;
|
struct snd_timer_id tid;
|
||||||
struct snd_timer *t;
|
struct snd_timer *t;
|
||||||
struct list_head *p;
|
struct list_head *p;
|
||||||
|
|
@ -1653,7 +1653,7 @@ static int snd_timer_user_ginfo(struct file *file,
|
||||||
|
|
||||||
ginfo = memdup_user(_ginfo, sizeof(*ginfo));
|
ginfo = memdup_user(_ginfo, sizeof(*ginfo));
|
||||||
if (IS_ERR(ginfo))
|
if (IS_ERR(ginfo))
|
||||||
return PTR_ERR(ginfo);
|
return PTR_ERR(no_free_ptr(ginfo));
|
||||||
|
|
||||||
tid = ginfo->tid;
|
tid = ginfo->tid;
|
||||||
memset(ginfo, 0, sizeof(*ginfo));
|
memset(ginfo, 0, sizeof(*ginfo));
|
||||||
|
|
@ -1682,7 +1682,6 @@ static int snd_timer_user_ginfo(struct file *file,
|
||||||
mutex_unlock(®ister_mutex);
|
mutex_unlock(®ister_mutex);
|
||||||
if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
|
if (err >= 0 && copy_to_user(_ginfo, ginfo, sizeof(*ginfo)))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
kfree(ginfo);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1804,9 +1803,8 @@ static int snd_timer_user_info(struct file *file,
|
||||||
struct snd_timer_info __user *_info)
|
struct snd_timer_info __user *_info)
|
||||||
{
|
{
|
||||||
struct snd_timer_user *tu;
|
struct snd_timer_user *tu;
|
||||||
struct snd_timer_info *info;
|
struct snd_timer_info *info __free(kfree) = NULL;
|
||||||
struct snd_timer *t;
|
struct snd_timer *t;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
tu = file->private_data;
|
tu = file->private_data;
|
||||||
if (!tu->timeri)
|
if (!tu->timeri)
|
||||||
|
|
@ -1827,9 +1825,8 @@ static int snd_timer_user_info(struct file *file,
|
||||||
info->resolution = snd_timer_hw_resolution(t);
|
info->resolution = snd_timer_hw_resolution(t);
|
||||||
spin_unlock_irq(&t->lock);
|
spin_unlock_irq(&t->lock);
|
||||||
if (copy_to_user(_info, info, sizeof(*_info)))
|
if (copy_to_user(_info, info, sizeof(*_info)))
|
||||||
err = -EFAULT;
|
return -EFAULT;
|
||||||
kfree(info);
|
return 0;
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_timer_user_params(struct file *file,
|
static int snd_timer_user_params(struct file *file,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user