lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 14 Jun 2018 13:30:21 +0200
From:   Takashi Iwai <tiwai@...e.de>
To:     "Zhouyang Jia" <jiazhouyang09@...il.com>
Cc:     <alsa-devel@...a-project.org>,
        "Bhumika Goyal" <bhumirks@...il.com>,
        "Jaroslav Kysela" <perex@...ex.cz>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] ALSA: sonicvibes: add error handling for snd_ctl_add

On Thu, 14 Jun 2018 13:22:18 +0200,
Zhouyang Jia wrote:
> 
> When snd_ctl_add fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling snd_ctl_add.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@...il.com>
> ---
> v1->v2:
> - Check the return value of snd_sonicvibes_create_gameport.
> ---
>  sound/pci/sonicvibes.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
> index a8abb15..75225b04 100644
> --- a/sound/pci/sonicvibes.c
> +++ b/sound/pci/sonicvibes.c
> @@ -1188,6 +1188,7 @@ SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0);
>  static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
>  {
>  	struct gameport *gp;
> +	int err;
>  
>  	sonic->gameport = gp = gameport_allocate_port();
>  	if (!gp) {
> @@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
>  
>  	gameport_register_port(gp);
>  
> -	snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
> +	err = snd_ctl_add(sonic->card,
> +		snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
> +	if (err < 0)
> +		return err;
>  
>  	return 0;
>  }
> @@ -1515,7 +1519,10 @@ static int snd_sonic_probe(struct pci_dev *pci,
>  		return err;
>  	}
>  
> -	snd_sonicvibes_create_gameport(sonic);
> +	if ((err = snd_sonicvibes_create_gameport(sonic)) < 0) {
> +		snd_card_free(card);
> +		return err;
> +        }

You don't need to inherit the old-fashioned style "if ((err = xxx)"
in a new code.  Check what checkpatch.pl complains.


thanks,

Takashi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ