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 A6AA41C6AB; Mon, 4 Mar 2024 21:54:24 +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=1709589264; cv=none; b=RpYDUGI4RWSfQObRk/zypU3tW07T0squUt/tTOc4C7QeFYNdb9fHqBnxc8lWiVKXfltlmq0CPeGC637maI6JAgtVrcPly/gLIrfsndjp33x4FMxACSg0XyQRtnuG758dDSZWHZNVxro/DbiIlRoUeRc95+aMwVlYkVWmInCNkxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709589264; c=relaxed/simple; bh=h9hC/XqOTE8AlEb0+fcJX6KUGxD3dJiR1XwSAgbxvnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I1VT4p25RkmJ2Ef/SICkjHoT4q/nCduldqyH2WhqJKzIPZtmg+ioQ1W7a5GoBP7ie5fq9UrBXCppnj2ogoF1OnKIWEtRNXomQ8by0jegT/xylrSYGwC/9WNmOkMAWK1j+d7iEYfFMXmTYl1+TLuuEexvbudhpTNk4wuS/FDhIyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p246ygM2; 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="p246ygM2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37953C433C7; Mon, 4 Mar 2024 21:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709589264; bh=h9hC/XqOTE8AlEb0+fcJX6KUGxD3dJiR1XwSAgbxvnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p246ygM2wO0gdBqdAMDS4I0ZGLmTAwjLjFU0VH4OJGLjyDVPMAANLkrhrbnJRxGuL MsaajGB+dFbjMa918PZkRuup6YTXOiuX202e/pF10bXQzNXkrLNL9aqDL3yBkKBoga xNn6Q4hLsQ2VUv5ucnaUNYiQsxhRNOm5SYlpBWBw= 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 5.15 42/84] power: supply: bq27xxx-i2c: Do not free non existing IRQ Date: Mon, 4 Mar 2024 21:24:15 +0000 Message-ID: <20240304211543.734321537@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240304211542.332206551@linuxfoundation.org> References: <20240304211542.332206551@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 b722ee2d7e142..4e5d773b3bf8d 100644 --- a/drivers/power/supply/bq27xxx_battery_i2c.c +++ b/drivers/power/supply/bq27xxx_battery_i2c.c @@ -209,7 +209,9 @@ static int 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