* [PATCH] ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl()
@ 2026-01-06 23:08 Nathan Chancellor
2026-01-07 8:05 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2026-01-06 23:08 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, linux-sound, llvm,
patches, kernel test robot, Nathan Chancellor
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 f3d233daf011 ("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 f3d233daf011 ("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: https://github.com/ClangBuiltLinux/linux/issues/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>
---
sound/core/pcm_native.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 4352c0a40f8d..30ace7112c27 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3286,6 +3286,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,
{
struct snd_xfern xfern;
struct snd_pcm_runtime *runtime = substream->runtime;
+ void *bufs __free(kfree) = NULL;
snd_pcm_sframes_t result;
if (runtime->state == SNDRV_PCM_STATE_OPEN)
@@ -3297,8 +3298,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,
if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
return -EFAULT;
- void *bufs __free(kfree) =
- memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *));
+ bufs = memdup_array_user(xfern.bufs, runtime->channels, sizeof(void *));
if (IS_ERR(bufs))
return PTR_ERR(bufs);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
---
base-commit: 94968fc3009d4bd7e7e1300abd7037f3dde585ed
change-id: 20260106-pcm_native-revert-var-move-free-for-old-clang-aa9a74d95338
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl()
2026-01-06 23:08 [PATCH] ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl() Nathan Chancellor
@ 2026-01-07 8:05 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-01-07 8:05 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Jaroslav Kysela, Takashi Iwai, Nick Desaulniers, Bill Wendling,
Justin Stitt, linux-sound, llvm, patches, kernel test robot
On Wed, 07 Jan 2026 00:08:18 +0100,
Nathan Chancellor wrote:
>
> 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 f3d233daf011 ("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 f3d233daf011 ("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: https://github.com/ClangBuiltLinux/linux/issues/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>
I hoped that this mess is addressed in the put_user() side, but it
doesn't seem happening, so I took your workaround now.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-07 8:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 23:08 [PATCH] ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl() Nathan Chancellor
2026-01-07 8:05 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox