Received: by 10.192.165.156 with SMTP id m28csp44020imm; Tue, 10 Apr 2018 16:02:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4817rHZxzt7T6iEZ3E8qUBGtlUA1Dj0W4LpetwxohpjTCbpESOayuUY+3+Z67onkxVuFnRu X-Received: by 2002:a17:902:5788:: with SMTP id l8-v6mr2345565pli.380.1523401353800; Tue, 10 Apr 2018 16:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401353; cv=none; d=google.com; s=arc-20160816; b=J0oxn87PqW6Oia6W5Ip3pjRGHwFURjTR3iZ5h004714pIKeQBOQt4+mnoUSYSUwrSy IcH8k1UyniRrvU7lgLv7eQ4WitO/LZt/uCu67+s8aJFUP7xtUGoNUik374pHCSJ5JEl6 rbJBh1K3iC2mIqdRq8JXwrVdtIpezQYCkV2biDs6RtbK/h0In1Nx+aRqePYPGkvbicGT MvzCgpDAgrIeXhnN0AlwlTTVtr1OTf1NPVdZsWbYSn+sz/HrWLHjo1QTdH6kJeNsFsmt dM8lB6MZtFDPakqBU35MZwycajbMsWYf8t7kaouASzqN5CahQnVyIc8fy4biLKNZ6AX2 +ApA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4RIVZnxHvMx2Q420PmsyvCiwQi8ChOR0djlnru9UcNE=; b=tgDUrk9XZtfwAGBRLedVj4d2s45tVB4nuImX0fASg5dgBjmYsZKySHhLVdWe7wbhMT Xj3Zuge1Uy4rCDJMHLG4OPLZrqOcQlB/CNY9wc8HyWGoohRAbEOl9uURF//bBUSIQ8SS u+Dn3a8znGAZzzXlm7KP9Q/oIpyM3DQcqmKcjrqdxeTmifq6AlSv41sCFGZuJN+DElbr SDLDDQjWJgORI27SVWqTOHcJUo1LflPRefKYgr5HpxdknY1iJs3XjECThEg3KICRhZCN 5qD6v7rGuDQXRy0AHpwrlPIoxWyDYw0HZF04P3B8q+7nfAgT1AvT1TYR380rRjhkuoJ9 SITA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si3553527plh.394.2018.04.10.16.01.57; Tue, 10 Apr 2018 16:02:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756385AbeDJW4w (ORCPT + 99 others); Tue, 10 Apr 2018 18:56:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43492 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755671AbeDJWgp (ORCPT ); Tue, 10 Apr 2018 18:36:45 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A9E79360; Tue, 10 Apr 2018 22:36:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen-Yu Tsai , Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.14 049/138] power: supply: axp288_charger: Properly stop work on probe-error / remove Date: Wed, 11 Apr 2018 00:23:59 +0200 Message-Id: <20180410212907.798255607@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede [ Upstream commit 165c2357744e41391902a2a72dd170beb60c28d5 ] Properly stop any work we may have queued on probe-errors / remove. Rather then adding a remove driver callback for this, and goto style error handling to probe, use a devm_action for this. The devm_action gets registered before we register any of the extcon notifiers which may queue the work, devm does cleanup in reverse order, so this ensures that the notifiers are removed before we cancel the work. Reviewed-by: Chen-Yu Tsai Signed-off-by: Hans de Goede Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/axp288_charger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -785,6 +785,14 @@ static int charger_init_hw_regs(struct a return 0; } +static void axp288_charger_cancel_work(void *data) +{ + struct axp288_chrg_info *info = data; + + cancel_work_sync(&info->otg.work); + cancel_work_sync(&info->cable.work); +} + static int axp288_charger_probe(struct platform_device *pdev) { int ret, i, pirq; @@ -836,6 +844,11 @@ static int axp288_charger_probe(struct p return ret; } + /* Cancel our work on cleanup, register this before the notifiers */ + ret = devm_add_action(dev, axp288_charger_cancel_work, info); + if (ret) + return ret; + /* Register for extcon notification */ INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); info->cable.nb[0].notifier_call = axp288_charger_handle_cable0_evt;