Skip to content

Commit

Permalink
ALSA: core: Drop superfluous no_free_ptr() for memdup_user() errors
Browse files Browse the repository at this point in the history
We used to wrap with no_free_ptr() for the return value from
memdup_user() with errors where the auto cleanup is applied.  This was
a workaround because the initial implementation of kfree auto-cleanup
checked only NULL pointers.

Since recently, though, the kfree auto-cleanup checks with
IS_ERR_OR_NULL() (by the commit cd7eb8f ("mm/slab: make
__free(kfree) accept error pointers")), hence those workarounds became
superfluous.  Let's drop them now.

Link: https://patch.msgid.link/20240902075246.3743-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Sep 2, 2024
1 parent f48bd50 commit 40a024b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
*/
params = memdup_user((void __user *)arg, sizeof(*params));
if (IS_ERR(params))
return PTR_ERR(no_free_ptr(params));
return PTR_ERR(params);

retval = snd_compress_check_input(params);
if (retval)
Expand Down
4 changes: 2 additions & 2 deletions sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ static int snd_ctl_elem_read_user(struct snd_card *card,

control = memdup_user(_control, sizeof(*control));
if (IS_ERR(control))
return PTR_ERR(no_free_ptr(control));
return PTR_ERR(control);

result = snd_power_ref_and_wait(card);
if (result)
Expand Down Expand Up @@ -1326,7 +1326,7 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,

control = memdup_user(_control, sizeof(*control));
if (IS_ERR(control))
return PTR_ERR(no_free_ptr(control));
return PTR_ERR(control);

card = file->card;
result = snd_power_ref_and_wait(card);
Expand Down
10 changes: 5 additions & 5 deletions sound/core/pcm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream,

params = memdup_user(_params, sizeof(*params));
if (IS_ERR(params))
return PTR_ERR(no_free_ptr(params));
return PTR_ERR(params);

err = snd_pcm_hw_refine(substream, params);
if (err < 0)
Expand Down Expand Up @@ -872,7 +872,7 @@ static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream,

params = memdup_user(_params, sizeof(*params));
if (IS_ERR(params))
return PTR_ERR(no_free_ptr(params));
return PTR_ERR(params);

err = snd_pcm_hw_params(substream, params);
if (err < 0)
Expand Down Expand Up @@ -3243,7 +3243,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,

bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels);
if (IS_ERR(bufs))
return PTR_ERR(no_free_ptr(bufs));
return PTR_ERR(bufs);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
result = snd_pcm_lib_writev(substream, bufs, xfern.frames);
else
Expand Down Expand Up @@ -4032,7 +4032,7 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,

oparams = memdup_user(_oparams, sizeof(*oparams));
if (IS_ERR(oparams))
return PTR_ERR(no_free_ptr(oparams));
return PTR_ERR(oparams);
snd_pcm_hw_convert_from_old_params(params, oparams);
err = snd_pcm_hw_refine(substream, params);
if (err < 0)
Expand Down Expand Up @@ -4061,7 +4061,7 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,

oparams = memdup_user(_oparams, sizeof(*oparams));
if (IS_ERR(oparams))
return PTR_ERR(no_free_ptr(oparams));
return PTR_ERR(oparams);

snd_pcm_hw_convert_from_old_params(params, oparams);
err = snd_pcm_hw_params(substream, params);
Expand Down
4 changes: 2 additions & 2 deletions sound/core/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ static int snd_timer_user_ginfo(struct file *file,

ginfo = memdup_user(_ginfo, sizeof(*ginfo));
if (IS_ERR(ginfo))
return PTR_ERR(no_free_ptr(ginfo));
return PTR_ERR(ginfo);

tid = ginfo->tid;
memset(ginfo, 0, sizeof(*ginfo));
Expand Down Expand Up @@ -2190,7 +2190,7 @@ static int snd_utimer_ioctl_create(struct file *file,

utimer_info = memdup_user(_utimer_info, sizeof(*utimer_info));
if (IS_ERR(utimer_info))
return PTR_ERR(no_free_ptr(utimer_info));
return PTR_ERR(utimer_info);

err = snd_utimer_create(utimer_info, &utimer);
if (err < 0)
Expand Down

0 comments on commit 40a024b

Please sign in to comment.