Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752838AbbDCAJ4 (ORCPT ); Thu, 2 Apr 2015 20:09:56 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:23944 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbbDCAJx (ORCPT ); Thu, 2 Apr 2015 20:09:53 -0400 X-AuditID: cbfee68f-f791c6d000004834-08-551dda4f14cb Message-id: <551DDA4F.1030705@samsung.com> Date: Fri, 03 Apr 2015 09:09:51 +0900 From: Chanwoo Choi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-version: 1.0 To: Robert Baldyga Cc: myungjoo.ham@samsung.com, rogerq@ti.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com Subject: Re: [PATCH v3 1/4] extcon: usb-gpio: register extcon device before IRQ registration References: <1427980385-21285-1-git-send-email-r.baldyga@samsung.com> <1427980385-21285-2-git-send-email-r.baldyga@samsung.com> In-reply-to: <1427980385-21285-2-git-send-email-r.baldyga@samsung.com> Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsWyRsSkUNf/lmyowZEGZYv5R86xWlzeNYfN YtGyVmaLtUfuslvcblzBZvHg8E52i55HWg7sHn1bVjF6HL+xncnj8ya5AOYoLpuU1JzMstQi fbsErozNT8wLvvNVNHesZW1gbOfpYuTkkBAwkTi1cDMrhC0mceHeerYuRi4OIYGljBIX/u5m 7GLkACv6Ol8DIr6IUWLzvGssEM4DIGfWYrBuXgEtiX9npzGC2CwCqhLzu9aBxdmA4vtf3GAD sUUFwiRWTr/CAlEvKPFj8j0wWwSo5s7H+ewgQ5kF5jFKLJ77nh0kISwQJ3H1yyuokxoZJfpO LQWbxCngJrG/ZTeYzSygI7G/dR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oCw2Ais5Rocj4wueSVxBsam5gZWRqZG1oY GZsrifMq2beFCAmkJ5akZqemFqQWwfQxcXBKNTDO3mmyUJAj9K7g2df2PbHPkpxsO2UtgxhU /lVxitZLWUYWnf65yWLfgfdCDpwBH609/05lfTw3YfKfCazc7MsruZ7cFP3cO1uV44D8RsN9 U3Z5XZlzLcvqet2qO63N/6+5VJ4/1B9hrmo04cOh1qUM3wU5N1w8FFX87NZae96V+3IN5/y7 ybdViaU4I9FQi7moOBEAY8t7tvYCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2094 Lines: 67 Hi Robert, On 04/02/2015 10:13 PM, 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 > --- > 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); > > Applied this patch for v4.1-rc. Thanks, Chanwoo Choi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/