[PATCH RFT] ALSA: scarlett2: Add missing error check when initialise Autogain Status

Robertus Diawan Chris posted 1 patch 1 month ago
sound/usb/mixer_scarlett2.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH RFT] ALSA: scarlett2: Add missing error check when initialise Autogain Status
Posted by Robertus Diawan Chris 1 month ago
When initialise new control with scarlett2_add_new_ctl() function for
Autogain Status, scarlett2_add_new_ctl() might throw an error. So, add
error check after initialise new control for Autogain Status.

This is reported by Coverity Scan with CID 1598781 as UNUSED_VALUE.

Fixes: 0a995e38dc44 ("ALSA: scarlett2: Add support for software-controllable input gain")
Signed-off-by: Robertus Diawan Chris <robertusdchris@gmail.com>
---
I don't have the device myself, so I can't test this change. Thank you.

 sound/usb/mixer_scarlett2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index 8eaa96222759..0f83f8981213 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -6707,6 +6707,8 @@ static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer)
 		err = scarlett2_add_new_ctl(
 			mixer, &scarlett2_autogain_status_ctl,
 			i, 1, s, &private->autogain_status_ctls[i]);
+		if (err < 0)
+			return err;
 	}
 
 	/* Add autogain target controls */

base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
-- 
2.54.0
Re: [PATCH RFT] ALSA: scarlett2: Add missing error check when initialise Autogain Status
Posted by Takashi Iwai 4 weeks, 1 day ago
On Fri, 08 May 2026 05:39:14 +0200,
Robertus Diawan Chris wrote:
> 
> When initialise new control with scarlett2_add_new_ctl() function for
> Autogain Status, scarlett2_add_new_ctl() might throw an error. So, add
> error check after initialise new control for Autogain Status.
> 
> This is reported by Coverity Scan with CID 1598781 as UNUSED_VALUE.
> 
> Fixes: 0a995e38dc44 ("ALSA: scarlett2: Add support for software-controllable input gain")
> Signed-off-by: Robertus Diawan Chris <robertusdchris@gmail.com>

Applied now.  Thanks.


Takashi