gpio-button-hotplug: leave platform_device.dev.platform_data untouched
authorFurong Xu <xfr@outlook.com>
Thu, 2 Mar 2017 09:00:32 +0000 (17:00 +0800)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Aug 2017 19:29:52 +0000 (21:29 +0200)
get platform_data from gpio_keys_button_dev.pdata, and fix a illegal pointer
dereference like this:

[   51.143776] gpio-keys-polled gpio-keys-polled: missing poll_interval value
[   51.150852] gpio-keys-polled: probe of gpio-keys-polled failed with error -22
[  828.159993] gpio-keys-polled gpio-keys-polled: no memory for button data
[  828.166821] gpio-keys-polled: probe of gpio-keys-polled failed with error -12

Signed-off-by: Furong Xu <xfr@outlook.com>
package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c

index 2bd3ff1813d3d86783d9b3b2bc092e3bc69e73a5..1aef23e8767a6e9bb0c81ab00bc9b2c0ef1d2f76 100644 (file)
@@ -474,7 +474,6 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
                        dev_err(dev, "missing platform data\n");
                        return -EINVAL;
                }
-               pdev->dev.platform_data = pdata;
        }
 
        if (polled && !pdata->poll_interval) {
@@ -559,7 +558,7 @@ static int gpio_keys_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       pdata = pdev->dev.platform_data;
+       pdata = bdev->pdata;
        for (i = 0; i < pdata->nbuttons; i++) {
                struct gpio_keys_button *button = &pdata->buttons[i];
                struct gpio_keys_button_data *bdata = &bdev->data[i];