From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795036187; b=x5qbpE78KiE4lA3AYdR7Bkd3xrx2hhIW7GtGOdZBrG1/xzsn9jA5XSkn4Vcuug7AjlWC xPiOaHoYZZrnfbAGDorHe3CC45eTYiOA2dkPOdvVWjYGR0ha/Wj2HZlAgDFcr55nEEEbs 7eKQXrMGYEqez/R4mrOf+tcHuYnA9JyB3M1VLYEi2LV5RBcBC3izKMV28kX4ccxJO9n4e Rr3HtlTVapsRM0fG+Em9Inca+ssa0XHK0Kwaioq0Sud4/ZV9iBwy6A4XTHQsQBwKVlznz +qK3CW40KpQf5Njp0KKoDMr0ccSkOATBB3KGsmiwdye4eBPCXjszpPI75WGsFVlWOXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795036187; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=pJ7ARPhAWaa5ukQCx9l8CDXwL6i3u5c05zQ+NVYMhcE=; b=rcE/s2Un0Ag+gFhmoPpi1t1sUqy6fp4cQSJ2zTDhdpRHVynsHMk7Ij4kLdKxWE8h/kgz qzRDVrguuGvkUEr/tf+F6ked/7sw8f1+4lyIOsOFfpphYBKL/jdcogdxRW4CCOpUmndKr BiHLkXsVOf7kXT1wvPUR6JrZZyki46QMtgX3bVD5u3YoXwPBvlf2nyZSRc7e3dy3T3qf/ X4jci/mey5LZANrfVfOBin6xPMcYEipGOEOxCWxgrT5nAQ/XcrKDrFo3mErOuwS8qzkZl FO48Oo9i9peVPWUSnLbqsNxwP4oK/zFTPrWgGipbeo6tp2yz620H+nJZ9Cm0wPL1OaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VLlKkM6S; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D70606A320; Wed, 18 Nov 2026 21:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VLlKkM6S Received: by smtp.kernel.org (Postfix) with ESMTPSA id F30611F000C4; Wed, 18 Nov 2026 21:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795036187; bh=pJ7ARPhAWaa5ukQCx9l8CDXwL6i3u5c05zQ+NVYMhcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VLlKkM6SN7OzIbD9Ggt7sEz5iqTbxMUiy8TX17ts9+iX2GWfY+jxUftV1okRL5c2M rtQUoO2JZp0Jlvg71uZ0nn1J/eyw4cSHd+XdSinjkU5TGwsqxBXRMu8PKFKWE2uaKm q+IBXGzfeSsfBmRkxmZWfUqxPhTgff9eo3T9JtpU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lee Jones , Hongyan Xu , Sasha Levin Subject: [PATCH 6.6 0927/3318] mfd: da903x: Cancel IRQ work during teardown Date: Wed, 18 Nov 2026 15:25:49 +0100 Message-ID: <20261118150347.351922793@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hongyan Xu [ Upstream commit fd2258999ecdc7164ef0cda2d4102e4558a5660f ] The IRQ handler disables the IRQ and schedules irq_work. Releasing the IRQ does not drain that work, which can continue to use the devm-allocated chip and notifier state. Manage both IRQ-work cancellation and subdevice removal with devres. Register the subdevice-removal action before requesting the IRQ, then add the IRQ-work action after the request. This avoids leaving a live IRQ without work cancellation if action registration fails. Devres cleanup then disables the IRQ and drains the work before releasing the IRQ and removing child devices. Register both actions before creating the children so partial probe failures use the same ordering. This issue was found by the author's in-house static analysis tool. The patch was reviewed by the author against the latest mainline tree. Fixes: 26b8f5e1e2d1 ("mfd: add base support for Dialog DA9030/DA9034 PMICs") Cc: stable@vger.kernel.org Suggested-by: Lee Jones Assisted-by: Codex:GPT-5 Signed-off-by: Hongyan Xu Link: https://patch.msgid.link/20260814153019.1114-1-getshell@seu.edu.cn Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/da903x.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c index e86b39de3303a..e4ad48e1f139b 100644 --- a/drivers/mfd/da903x.c +++ b/drivers/mfd/da903x.c @@ -421,6 +421,14 @@ static irqreturn_t da903x_irq_handler(int irq, void *data) return IRQ_HANDLED; } +static void da903x_cancel_irq_work(void *data) +{ + struct da903x_chip *chip = data; + + disable_irq(chip->client->irq); + cancel_work_sync(&chip->irq_work); +} + static const struct da903x_chip_ops da903x_ops[] = { [0] = { .init_chip = da9030_init_chip, @@ -456,6 +464,13 @@ static int da903x_remove_subdevs(struct da903x_chip *chip) return device_for_each_child(chip->dev, NULL, __remove_subdev); } +static void da903x_remove_subdevs_action(void *data) +{ + struct da903x_chip *chip = data; + + da903x_remove_subdevs(chip); +} + static int da903x_add_subdevs(struct da903x_chip *chip, struct da903x_platform_data *pdata) { @@ -484,7 +499,6 @@ static int da903x_add_subdevs(struct da903x_chip *chip, return 0; failed: - da903x_remove_subdevs(chip); return ret; } @@ -520,6 +534,11 @@ static int da903x_probe(struct i2c_client *client) chip->ops->mask_events(chip, chip->events_mask); chip->ops->read_events(chip, &tmp); + ret = devm_add_action_or_reset(&client->dev, + da903x_remove_subdevs_action, chip); + if (ret) + return ret; + ret = devm_request_irq(&client->dev, client->irq, da903x_irq_handler, IRQF_TRIGGER_FALLING, "da903x", chip); @@ -529,14 +548,12 @@ static int da903x_probe(struct i2c_client *client) return ret; } - return da903x_add_subdevs(chip, pdata); -} - -static void da903x_remove(struct i2c_client *client) -{ - struct da903x_chip *chip = i2c_get_clientdata(client); + ret = devm_add_action_or_reset(&client->dev, da903x_cancel_irq_work, + chip); + if (ret) + return ret; - da903x_remove_subdevs(chip); + return da903x_add_subdevs(chip, pdata); } static struct i2c_driver da903x_driver = { @@ -544,7 +561,6 @@ static struct i2c_driver da903x_driver = { .name = "da903x", }, .probe = da903x_probe, - .remove = da903x_remove, .id_table = da903x_id_table, }; -- 2.53.0