ALSA: pcmtest: Reject invalid fill_mode values
Subsystems (2)
PATCH 1/1 ALSA: pcmtest: Reject invalid fill_mode values
The fill_block() function handles only fill_mode 0 (random) and 1 (pattern). With any other value it writes nothing and does not move the buffer position. A capture stream then gets no data, and a read fails with -EIO after the timeout. Nothing in the kernel log says why.
Check the value in a set callback, so a bad value is rejected both when the module is loaded and when the parameter is written.
--- sound/drivers/pcmtest.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
sound/drivers/pcmtest.c +20 -1
@@ -72,13 +72,32 @@ static u8 playback_capture_test;static u8 ioctl_reset_test;static struct dentry *driver_debug_dir; +static int fill_mode_set (const char *val,const struct kernel_param *kp) +{ +short mode; +int err; + + err =kstrtos16 (val,0 , &mode); +if (err) +return err; +if (mode !=FILL_MODE_RAND && mode !=FILL_MODE_PAT ) +return -EINVAL ; + fill_mode = mode; +return 0 ; +} + +static const struct kernel_param_ops fill_mode_ops = { + .set = fill_mode_set, + .get = param_get_short, +}; +module_param (index, int,0444 );MODULE_PARM_DESC (index,"Index value for pcmtest soundcard" );module_param (id, charp,0444 );MODULE_PARM_DESC (id,"ID string for pcmtest soundcard" );module_param (enable, bool,0444 );MODULE_PARM_DESC (enable,"Enable pcmtest soundcard." ); -module_param (fill_mode, short,0600 ); +module_param_cb (fill_mode, &fill_mode_ops, &fill_mode,0600 );MODULE_PARM_DESC (fill_mode,"Buffer fill mode: rand(0) or pattern(1)" );module_param (inject_delay, int,0600 );MODULE_PARM_DESC (inject_delay,"Inject delays during playback/capture (in jiffies)" );
Signature · 1 line
2.43.0
Quoted 6 lines · HyeongJun An
The
fill_block()function handles onlyfill_mode0 (random) and 1 (pattern). With any other value it writes nothing and does not move the buffer position. A capture stream then gets no data, and a read fails with-EIOafter the timeout. Nothing in the kernel log says why.
Quoted 6 lines
Check the value in a set callback, so a bad value is rejected both when the module is loaded and when the parameter is written.
Fixes 315a3d57c64c ("ALSA: Implement the new Virtual PCM Test Driver")Assisted-by Claude:claude-opus-5-5Signed-off-by HyeongJun An <[email protected]>
Applied now. Thanks.
Takashi