From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753335AbbCaIhU (ORCPT ); Tue, 31 Mar 2015 04:37:20 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:45311 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752619AbbCaIhO (ORCPT ); Tue, 31 Mar 2015 04:37:14 -0400 Message-ID: <551A5CB4.2020302@ti.com> Date: Tue, 31 Mar 2015 11:37:08 +0300 From: Roger Quadros User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Robert Baldyga , CC: , , , Subject: Re: [PATCH 1/4] extcon: usb-gpio: register extcon device before IRQ registration References: <1427787963-23562-1-git-send-email-r.baldyga@samsung.com> <1427787963-23562-2-git-send-email-r.baldyga@samsung.com> In-Reply-To: <1427787963-23562-2-git-send-email-r.baldyga@samsung.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/03/15 10:46, Robert Baldyga wrote: > 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 Acked-by: Roger Quadros cheers, -roger > --- > drivers/extcon/extcon-usb-gpio.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c > index 3f0bad3..f6aa99d 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) > return PTR_ERR(info->id_gpiod); > } > > + info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); > + if (IS_ERR(info->edev)) { > + dev_err(dev, "failed to allocate extcon device\n"); > + return -ENOMEM; > + } > + > + ret = devm_extcon_dev_register(dev, info->edev); > + if (ret < 0) { > + dev_err(dev, "failed to register extcon device\n"); > + return ret; > + } > + > ret = gpiod_set_debounce(info->id_gpiod, > USB_GPIO_DEBOUNCE_MS * 1000); > if (ret < 0) > @@ -142,18 +154,6 @@ static int usb_extcon_probe(struct platform_device *pdev) > return ret; > } > > - info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable); > - if (IS_ERR(info->edev)) { > - dev_err(dev, "failed to allocate extcon device\n"); > - return -ENOMEM; > - } > - > - ret = devm_extcon_dev_register(dev, info->edev); > - if (ret < 0) { > - dev_err(dev, "failed to register extcon device\n"); > - return ret; > - } > - > platform_set_drvdata(pdev, info); > device_init_wakeup(dev, 1); > >