diff options
author | Robert Baldyga <r.baldyga@samsung.com> | 2015-04-02 09:13:02 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2015-04-26 22:06:05 -0400 |
commit | bc1aabad39f42fa293f2a944fd9327bba27b59cd (patch) | |
tree | f7f4527037d92b73b54e1a4c151c6447aa016761 | |
parent | b787f68c36d49bb1d9236f403813641efa74a031 (diff) |
extcon: usb-gpio: register extcon device before IRQ registration
IRQ handler touches info->edev, so if interrupt occurs before extcon
device initialization it can cause NULL pointer dereference. Doing extcon
initialization before IRQ handler registration fixes this problem.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | drivers/extcon/extcon-usb-gpio.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index de67fce18984..e45d1f13f445 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c | |||
@@ -119,6 +119,18 @@ static int usb_extcon_probe(struct platform_device *pdev) | |||
119 | return PTR_ERR(info->id_gpiod); | 119 | return PTR_ERR(info->id_gpiod); |
120 | } | 120 | } |
121 | 121 | ||
122 | info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); | ||
123 | if (IS_ERR(info->edev)) { | ||
124 | dev_err(dev, "failed to allocate extcon device\n"); | ||
125 | return -ENOMEM; | ||
126 | } | ||
127 | |||
128 | ret = devm_extcon_dev_register(dev, info->edev); | ||
129 | if (ret < 0) { | ||
130 | dev_err(dev, "failed to register extcon device\n"); | ||
131 | return ret; | ||
132 | } | ||
133 | |||
122 | ret = gpiod_set_debounce(info->id_gpiod, | 134 | ret = gpiod_set_debounce(info->id_gpiod, |
123 | USB_GPIO_DEBOUNCE_MS * 1000); | 135 | USB_GPIO_DEBOUNCE_MS * 1000); |
124 | if (ret < 0) | 136 | if (ret < 0) |
@@ -142,18 +154,6 @@ static int usb_extcon_probe(struct platform_device *pdev) | |||
142 | return ret; | 154 | return ret; |
143 | } | 155 | } |
144 | 156 | ||
145 | info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); | ||
146 | if (IS_ERR(info->edev)) { | ||
147 | dev_err(dev, "failed to allocate extcon device\n"); | ||
148 | return -ENOMEM; | ||
149 | } | ||
150 | |||
151 | ret = devm_extcon_dev_register(dev, info->edev); | ||
152 | if (ret < 0) { | ||
153 | dev_err(dev, "failed to register extcon device\n"); | ||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | platform_set_drvdata(pdev, info); | 157 | platform_set_drvdata(pdev, info); |
158 | device_init_wakeup(dev, 1); | 158 | device_init_wakeup(dev, 1); |
159 | 159 | ||