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 DC55C1EB5A; Mon, 4 Mar 2024 21:45:06 +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=1709588707; cv=none; b=QeTaLPnEcXdvIPZ3F5rfBTblC8M6e2e2Wxe6MxW0As7r/o5V7VfX4kcIYeGhZ7PWKfJ5499GuPtcVFOHDgX8epNT7ZQuK1319DQSiiD/6tJGd1oX3k4V4MKpjB7zfTnaLTAzg1xGYyepEADjorZRBqwwObLQ3VAlCgcVhfEivwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709588707; c=relaxed/simple; bh=oOH5qJFaN5lG5micC0KsvclJ1LSbi0nTbZL8g41pFV4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVHCvR1VDYSdkmucvW2lpZriHxLUT1SFscFNJ9oV9lmvG0qQptiKub/wKaOHQS79/PdHg7643VZRXFlgusNA3l4G5qer+rC7Gzvtonwx+DINCXgKj214iK5J7k3UK1rg6Y/UovG+I11WMe0eLQKkgnPInDTqo67+PlWiOoHa4j4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Xe9J0cw/; 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="Xe9J0cw/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DFF1C43394; Mon, 4 Mar 2024 21:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709588706; bh=oOH5qJFaN5lG5micC0KsvclJ1LSbi0nTbZL8g41pFV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xe9J0cw/RtFiSiLB8K1/TvIa8qglN9P36eb45n42e9H605HKrDBhGoOI6Ua20l4/i ckPmY0NZRAh66zHrmauizzvh1rLPb3QO8c2giMOtqwVYoFQhPLK6fIsqZT+n6nHEZu eImzIRjOyMk1EkWGojJeQLLB8cmQFZ9bWzEb+GiM= 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.1 065/215] power: supply: bq27xxx-i2c: Do not free non existing IRQ Date: Mon, 4 Mar 2024 21:22:08 +0000 Message-ID: <20240304211559.046329714@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240304211556.993132804@linuxfoundation.org> References: <20240304211556.993132804@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.1-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 0713a52a25107..17b37354e32c0 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