aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>2015-01-12 15:42:34 -0500
committerTakashi Iwai <tiwai@suse.de>2015-01-12 16:23:56 -0500
commita248ce068f560ece6b72eb75b54380e3d800cbab (patch)
treed17d1c3e444171ac2cf3c150ce9c19d82a618706
parenteaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff)
staging: line6: toneport.c: Fix for possible null pointer dereference
The NULL check was done to late, and there it was a risk of a possible null pointer dereference. This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--drivers/staging/line6/toneport.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index 69437158d383..660dc3f2aa61 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -433,12 +433,16 @@ void line6_toneport_reset_resume(struct usb_line6_toneport *toneport)
433void line6_toneport_disconnect(struct usb_interface *interface) 433void line6_toneport_disconnect(struct usb_interface *interface)
434{ 434{
435 struct usb_line6_toneport *toneport; 435 struct usb_line6_toneport *toneport;
436 struct snd_line6_pcm *line6pcm;
436 u16 idProduct; 437 u16 idProduct;
437 438
438 if (interface == NULL) 439 if (interface == NULL)
439 return; 440 return;
440 441
441 toneport = usb_get_intfdata(interface); 442 toneport = usb_get_intfdata(interface);
443 if (NULL == toneport)
444 return;
445
442 del_timer_sync(&toneport->timer); 446 del_timer_sync(&toneport->timer);
443 idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct); 447 idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
444 448
@@ -447,13 +451,10 @@ void line6_toneport_disconnect(struct usb_interface *interface)
447 device_remove_file(&interface->dev, &dev_attr_led_green); 451 device_remove_file(&interface->dev, &dev_attr_led_green);
448 } 452 }
449 453
450 if (toneport != NULL) { 454 line6pcm = toneport->line6.line6pcm;
451 struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm; 455 if (line6pcm != NULL) {
452 456 line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
453 if (line6pcm != NULL) { 457 line6_pcm_disconnect(line6pcm);
454 line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
455 line6_pcm_disconnect(line6pcm);
456 }
457 } 458 }
458 459
459 toneport_destruct(interface); 460 toneport_destruct(interface);