Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbdFAQS4 (ORCPT ); Thu, 1 Jun 2017 12:18:56 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:33237 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113AbdFAPo5 (ORCPT ); Thu, 1 Jun 2017 11:44:57 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Sebastian Reichel" , "Liam Breck" , "Liam Breck" , "Mark Greer" , "Tony Lindgren" Date: Thu, 01 Jun 2017 16:43:15 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 060/212] power: supply: bq24190_charger: Install irq_handler_thread() at end of probe() In-Reply-To: X-SA-Exim-Connect-IP: 82.70.136.246 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2711 Lines: 99 3.16.44-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Liam Breck commit d62acc5ef0621463446091ebd7a345e06e9ab80c upstream. The device specific data is not fully initialized on request_threaded_irq(). This may cause a crash when the IRQ handler tries to reference them. Fix the issue by installing IRQ handler at the end of the probe. Fixes: d7bf353fd0aa3 ("bq24190_charger: Add support for TI BQ24190 Battery Charger") Signed-off-by: Liam Breck Acked-by: Mark Greer Acked-by: Tony Lindgren Signed-off-by: Sebastian Reichel [bwh: Backported to 3.16: adjust filename, context] Signed-off-by: Ben Hutchings --- drivers/power/bq24190_charger.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -1398,22 +1398,13 @@ static int bq24190_probe(struct i2c_clie return -EINVAL; } - ret = devm_request_threaded_irq(dev, bdi->irq, NULL, - bq24190_irq_handler_thread, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "bq24190-charger", bdi); - if (ret < 0) { - dev_err(dev, "Can't set up irq handler\n"); - goto out1; - } - pm_runtime_enable(dev); pm_runtime_resume(dev); ret = bq24190_hw_init(bdi); if (ret < 0) { dev_err(dev, "Hardware init failed\n"); - goto out2; + goto out1; } bq24190_charger_init(&bdi->charger); @@ -1421,7 +1412,7 @@ static int bq24190_probe(struct i2c_clie ret = power_supply_register(dev, &bdi->charger); if (ret) { dev_err(dev, "Can't register charger\n"); - goto out2; + goto out1; } bq24190_battery_init(&bdi->battery); @@ -1429,24 +1420,34 @@ static int bq24190_probe(struct i2c_clie ret = power_supply_register(dev, &bdi->battery); if (ret) { dev_err(dev, "Can't register battery\n"); - goto out3; + goto out2; } ret = bq24190_sysfs_create_group(bdi); if (ret) { dev_err(dev, "Can't create sysfs entries\n"); + goto out3; + } + + ret = devm_request_threaded_irq(dev, bdi->irq, NULL, + bq24190_irq_handler_thread, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "bq24190-charger", bdi); + if (ret < 0) { + dev_err(dev, "Can't set up irq handler\n"); goto out4; } return 0; out4: - power_supply_unregister(&bdi->battery); + bq24190_sysfs_remove_group(bdi); out3: - power_supply_unregister(&bdi->charger); + power_supply_unregister(&bdi->battery); out2: - pm_runtime_disable(dev); + power_supply_unregister(&bdi->charger); out1: + pm_runtime_disable(dev); if (bdi->gpio_int) gpio_free(bdi->gpio_int);