diff mbox

[4/6] ALSA: usb: Fix potential NULL pointer dereference in comm.c

Message ID 1353488819-13902-4-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat Nov. 21, 2012, 9:06 a.m. UTC
'rt' was dereferenced before the NULL check.
Moved the code after the check.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
Build tested and based on linux-next 20121115.
---
 sound/usb/6fire/comm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Takashi Iwai Nov. 21, 2012, 9:45 a.m. UTC | #1
At Wed, 21 Nov 2012 14:36:57 +0530,
Sachin Kamat wrote:
> 
> 'rt' was dereferenced before the NULL check.
> Moved the code after the check.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Applied (with a minor change in the subject line).
Thanks.


Takashi


> ---
> Build tested and based on linux-next 20121115.
> ---
>  sound/usb/6fire/comm.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
> index 6c3d531..1a75c36 100644
> --- a/sound/usb/6fire/comm.c
> +++ b/sound/usb/6fire/comm.c
> @@ -129,12 +129,13 @@ int __devinit usb6fire_comm_init(struct sfire_chip *chip)
>  {
>  	struct comm_runtime *rt = kzalloc(sizeof(struct comm_runtime),
>  			GFP_KERNEL);
> -	struct urb *urb = &rt->receiver;
> +	struct urb *urb;
>  	int ret;
>  
>  	if (!rt)
>  		return -ENOMEM;
>  
> +	urb = &rt->receiver;
>  	rt->serial = 1;
>  	rt->chip = chip;
>  	usb_init_urb(urb);
> -- 
> 1.7.4.1
>
diff mbox

Patch

diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
index 6c3d531..1a75c36 100644
--- a/sound/usb/6fire/comm.c
+++ b/sound/usb/6fire/comm.c
@@ -129,12 +129,13 @@  int __devinit usb6fire_comm_init(struct sfire_chip *chip)
 {
 	struct comm_runtime *rt = kzalloc(sizeof(struct comm_runtime),
 			GFP_KERNEL);
-	struct urb *urb = &rt->receiver;
+	struct urb *urb;
 	int ret;
 
 	if (!rt)
 		return -ENOMEM;
 
+	urb = &rt->receiver;
 	rt->serial = 1;
 	rt->chip = chip;
 	usb_init_urb(urb);