Input: w90p910_keypad - move a dereference below a NULL test
authorJulia Lawall <julia@diku.dk>
Sun, 30 Aug 2009 18:30:48 +0000 (11:30 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 30 Aug 2009 18:55:47 +0000 (11:55 -0700)
We should first check whether platform data is NULL or not, before
dereferencing it to get the keymap.

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/keyboard/w90p910_keypad.c

index 2d03dd0..6032def 100644 (file)
@@ -120,7 +120,7 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev)
 {
        const struct w90p910_keypad_platform_data *pdata =
                                                pdev->dev.platform_data;
-       const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
+       const struct matrix_keymap_data *keymap_data;
        struct w90p910_keypad *keypad;
        struct input_dev *input_dev;
        struct resource *res;
@@ -132,6 +132,8 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
+       keymap_data = pdata->keymap_data;
+
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "failed to get keypad irq\n");