From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F26242071; Mon, 4 Mar 2024 21:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709587672; cv=none; b=gd6iNuEUvBVQfRFOGZSjCZ3N3TmYFPMwWbMs9vwHoUK9swVbfbj5cpf96fsv67XYAUduzfxcBz2Qf9I8sQOFMDEA0MhOG8O+ewVd1zTjpe62ROrO2kTJizJ67k9xf0zG7kYcumMo+9+zEa6x/vJHIWg4CpR8oTl1SDglb2a+Bdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709587672; c=relaxed/simple; bh=nQpGR3/n53Fa2EnEOkbS34OXDZBY+/jdn/xkIYlvxDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MNPUjkCTxMcvBD+P0gxF0SrWU73VLppzR2zAbkR/yeuAzD0KKRpE+H7Nb1PYsMB7Xov9IuRb8YqK+QmTblGdIrqPJcVd6RyZteHWPZZ7EgqTOUjOqYJxuxbKsAjWfMsOiMoORCpQA684rIa1ibxqtevw+8j4J1vTZJej/r4hM5Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bilIVyY4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bilIVyY4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E625DC433C7; Mon, 4 Mar 2024 21:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709587672; bh=nQpGR3/n53Fa2EnEOkbS34OXDZBY+/jdn/xkIYlvxDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bilIVyY40KFCRaK2vhHJEdJwnXxhF/yg3SNmHpyj7/JTSZNQEQ4l7nOrFgcRZLB73 J9gC8+UwwqAdO2sjwztL4kxcgJ12XUb6BVrtrRVTYJbd0pLjWRyKV0JGWd0UMeHmY9 BBC7Ott7PDGLE6qm+vqRxLdnsyVCdQN8+48RA22w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 6.7 046/162] power: supply: bq27xxx-i2c: Do not free non existing IRQ Date: Mon, 4 Mar 2024 21:21:51 +0000 Message-ID: <20240304211553.325039838@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240304211551.833500257@linuxfoundation.org> References: <20240304211551.833500257@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede [ Upstream commit 2df70149e73e79783bcbc7db4fa51ecef0e2022c ] The bq27xxx i2c-client may not have an IRQ, in which case client->irq will be 0. bq27xxx_battery_i2c_probe() already has an if (client->irq) check wrapping the request_threaded_irq(). But bq27xxx_battery_i2c_remove() unconditionally calls free_irq(client->irq) leading to: [ 190.310742] ------------[ cut here ]------------ [ 190.310843] Trying to free already-free IRQ 0 [ 190.310861] WARNING: CPU: 2 PID: 1304 at kernel/irq/manage.c:1893 free_irq+0x1b8/0x310 Followed by a backtrace when unbinding the driver. Add an if (client->irq) to bq27xxx_battery_i2c_remove() mirroring probe() to fix this. Fixes: 444ff00734f3 ("power: supply: bq27xxx: Fix I2C IRQ race on remove") Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20240215155133.70537-1-hdegoede@redhat.com Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/bq27xxx_battery_i2c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c index 9b5475590518f..886e0a8e2abd1 100644 --- a/drivers/power/supply/bq27xxx_battery_i2c.c +++ b/drivers/power/supply/bq27xxx_battery_i2c.c @@ -209,7 +209,9 @@ static void bq27xxx_battery_i2c_remove(struct i2c_client *client) { struct bq27xxx_device_info *di = i2c_get_clientdata(client); - free_irq(client->irq, di); + if (client->irq) + free_irq(client->irq, di); + bq27xxx_battery_teardown(di); mutex_lock(&battery_mutex); -- 2.43.0