ALSA: snd-usb-caiaq: Fix NULL dereference in input.c
authorWilliam Light <wrl@illest.net>
Mon, 10 Oct 2011 15:54:22 +0000 (15:54 +0000)
committerTakashi Iwai <tiwai@suse.de>
Thu, 13 Oct 2011 06:16:42 +0000 (08:16 +0200)
There was a case where a newly-registered input device could be opened before
a necessary variable in the device structure was set. When code tried to use
the variable in the URB reply callback, it would cause an Oops.

This fix sets the aforementioned variable before calling input_register_device.

Signed-off-by: William Light <wrl@illest.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/caiaq/input.c

index a213813487bd77b02211597a8448a9dde44d32ef..9efb92e4090dba70c89b3b012508fe498708bb63 100644 (file)
@@ -664,15 +664,17 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
        for (i = 0; i < input->keycodemax; i++)
                __set_bit(dev->keycode[i], input->keybit);
 
+       dev->input_dev = input;
+
        ret = input_register_device(input);
        if (ret < 0)
                goto exit_free_idev;
 
-       dev->input_dev = input;
        return 0;
 
 exit_free_idev:
        input_free_device(input);
+       dev->input_dev = NULL;
        return ret;
 }