Skip to content

Commit 1735213

Browse files
nathanchanceSasha Levin
authored andcommitted
ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl()
[ Upstream commit 0585c53 ] When building with clang older than 17 targeting architectures that use asm goto for their get_user() and put_user(), such as arm64, after commit f3d233d ("ALSA: pcm: Relax __free() variable declarations"), there are bogus errors around skipping over a variable declared with the cleanup attribute: sound/core/pcm_native.c:3308:6: error: cannot jump from this asm goto statement to one of its possible targets if (put_user(result, &_xfern->result)) ^ ... arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm' asm goto( ^ sound/core/pcm_native.c:3295:6: note: possible target of asm goto statement if (put_user(0, &_xfern->result)) ^ ... sound/core/pcm_native.c:3300:8: note: jump exits scope of variable with __attribute__((cleanup)) void *bufs __free(kfree) = ^ clang-17 fixed a bug in clang's jump scope checker [1] where all labels in a function were checked as valid targets for all asm goto instances in a function, regardless of whether they were actual targets in a paricular asm goto's provided list of labels. To workaround this, revert the change done to snd_pcm_xfern_frames_ioctl() by commit f3d233d ("ALSA: pcm: Relax __free() variable declarations") to avoid a variable declared with cleanup from existing between multiple uses of asm goto. There are no other uses of cleanup in this function so there should be low risk from moving this variable back to the top of the function. Link: ClangBuiltLinux/linux#1886 [1] Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202512190802.i4Jzbcsl-lkp@intel.com/ Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://patch.msgid.link/20260106-pcm_native-revert-var-move-free-for-old-clang-v1-1-06a03693423d@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ddf81d3 commit 1735213

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/pcm_native.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,6 +3291,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,
32913291
{
32923292
struct snd_xfern xfern;
32933293
struct snd_pcm_runtime *runtime = substream->runtime;
3294+
void *bufs __free(kfree) = NULL;
32943295
snd_pcm_sframes_t result;
32953296

32963297
if (runtime->state == SNDRV_PCM_STATE_OPEN)
@@ -3302,8 +3303,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,
33023303
if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
33033304
return -EFAULT;
33043305

3305-
void *bufs __free(kfree) =
3306-
memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *));
3306+
bufs = memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *));
33073307
if (IS_ERR(bufs))
33083308
return PTR_ERR(bufs);
33093309
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)

0 commit comments

Comments
 (0)