summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>2015-01-12 12:42:34 -0800
committerTakashi Iwai <tiwai@suse.de>2015-01-12 22:23:56 +0100
commita248ce068f560ece6b72eb75b54380e3d800cbab (patch)
treed17d1c3e444171ac2cf3c150ce9c19d82a618706
parenteaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff)
downloadop-kernel-dev-a248ce068f560ece6b72eb75b54380e3d800cbab.zip
op-kernel-dev-a248ce068f560ece6b72eb75b54380e3d800cbab.tar.gz
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 6943715..660dc3f 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)
void line6_toneport_disconnect(struct usb_interface *interface)
{
struct usb_line6_toneport *toneport;
+ struct snd_line6_pcm *line6pcm;
u16 idProduct;
if (interface == NULL)
return;
toneport = usb_get_intfdata(interface);
+ if (NULL == toneport)
+ return;
+
del_timer_sync(&toneport->timer);
idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct);
@@ -447,13 +451,10 @@ void line6_toneport_disconnect(struct usb_interface *interface)
device_remove_file(&interface->dev, &dev_attr_led_green);
}
- if (toneport != NULL) {
- struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm;
-
- if (line6pcm != NULL) {
- line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
- line6_pcm_disconnect(line6pcm);
- }
+ line6pcm = toneport->line6.line6pcm;
+ if (line6pcm != NULL) {
+ line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR);
+ line6_pcm_disconnect(line6pcm);
}
toneport_destruct(interface);
OpenPOWER on IntegriCloud