Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753189AbbDBNO5 (ORCPT ); Thu, 2 Apr 2015 09:14:57 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:51934 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbbDBNNf (ORCPT ); Thu, 2 Apr 2015 09:13:35 -0400 X-AuditID: cbfee61a-f79c06d000004e71-d8-551d407c4d9b From: Robert Baldyga To: cw00.choi@samsung.com 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, Robert Baldyga Subject: [PATCH v3 1/4] extcon: usb-gpio: register extcon device before IRQ registration Date: Thu, 02 Apr 2015 15:13:02 +0200 Message-id: <1427980385-21285-2-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1427980385-21285-1-git-send-email-r.baldyga@samsung.com> References: <1427980385-21285-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e+xoG6Ng2yowf7J1hbXvzxntZh/5Byr xeVdc9gsFi1rZbZYe+Quu8XtxhVsFg8O72S36Hmk5cDh0bdlFaPH8RvbmTw+b5ILYI7isklJ zcksSy3St0vgyph0+whTwTzeinszkhsY/3B1MXJwSAiYSCxbI9rFyAlkiklcuLeerYuRi0NI YDqjxOrlPSwQzk9GiSePVjGBVLEJ6Ehs+T6BEaRZREBSomWfGUgNs8AxRok3v5+zgNQIC0RJ PN2/jxHEZhFQlbh9/wsziM0r4Cqx9cwHFohtchInj01mBbE5Bdwk7m7ZDhYXAqo5uPIW2wRG 3gWMDKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgsPomdQOxpUNFocYBTgYlXh4M/bIhAqx JpYVV+YeYpTgYFYS4X2gLRsqxJuSWFmVWpQfX1Sak1p8iFGag0VJnFfJvi1ESCA9sSQ1OzW1 ILUIJsvEwSnVwOh51fvGXV+bqps3GGe+uX2zWOOlW3HP7x3TRGbpXRZzK5tn8CVMvvTFWu1u 48NOS1k4Dt9L+Bn6Luy4/sLOW8t4vP0ufX1/etLB3be2x1cnqm+SmWB1fN6kJg/uWoH+jvBL fu1zQztWJ6heEt1+pHfyi1tmSpcaTSe1eb49e31q3YyIqqc3mC4psRRnJBpqMRcVJwIAjnwa ox8CAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1884 Lines: 60 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); -- 1.9.1 -- 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/