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 630652FA0FD; Tue, 12 Aug 2025 17:37:16 +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=1755020237; cv=none; b=VZgLjGnvgdM+x3FCerwK5wqyzFllKsKBMpfEuQL3Yiq2idCt7kumq0b5jmYktYJgnNZ3fIYCu1cC4QGBNXtNdEFbMlwY28Vw6QXMHuMxW/1SZ3F4VrIhfh3sW2+xF2e7lA3vis6Re5272ImG1H2UF1gfBgsOFWgD1B3Zpv+l950= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755020237; c=relaxed/simple; bh=NGAcDRaf5w7d/uyJaLo+5mfoiM14gjwvDjYMXm1B2EE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ANvLc53/rDY4LIeoS/szP8bE+Y5l9ILEXm9ATk2L9m6IN1vwpLude1oHZ/24KFf8cwOlZNESnfHT7LrRZGFlfhCNOTyGtQ0LEqDekh37lLr/JK1TzOdUSnhHdYjFKtrOgYBQx3Q23P+/tC+p7BbDY0Qxkdgb7I2fD1XryQk+dd8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w5exGu9h; 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="w5exGu9h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DE95C4CEF0; Tue, 12 Aug 2025 17:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755020236; bh=NGAcDRaf5w7d/uyJaLo+5mfoiM14gjwvDjYMXm1B2EE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w5exGu9h1QqqggvZdM2w69YfIuc2ZrsiOozZOKjk3kaSH/nfc8nmZNKCMuxDsInR0 4zOyN6DcP3MkguPSgPK+udBO279DU2BHPIsymXugLc40J1H7xLsCTdt4/zHUsqnaIj qgfq2iBRIkFy3ulRr3nImZ0SgrX6w3IwvHovZHDc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alessandro Carminati , Mark Brown , Sasha Levin Subject: [PATCH 6.1 002/253] regulator: core: fix NULL dereference on unbind due to stale coupling data Date: Tue, 12 Aug 2025 19:26:30 +0200 Message-ID: <20250812172948.786063157@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812172948.675299901@linuxfoundation.org> References: <20250812172948.675299901@linuxfoundation.org> User-Agent: quilt/0.68 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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alessandro Carminati [ Upstream commit ca46946a482238b0cdea459fb82fc837fb36260e ] Failing to reset coupling_desc.n_coupled after freeing coupled_rdevs can lead to NULL pointer dereference when regulators are accessed post-unbind. This can happen during runtime PM or other regulator operations that rely on coupling metadata. For example, on ridesx4, unbinding the 'reg-dummy' platform device triggers a panic in regulator_lock_recursive() due to stale coupling state. Ensure n_coupled is set to 0 to prevent access to invalid pointers. Signed-off-by: Alessandro Carminati Link: https://patch.msgid.link/20250626083809.314842-1-acarmina@redhat.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 29c9171e923a2..7e6ff7e72784b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5423,6 +5423,7 @@ static void regulator_remove_coupling(struct regulator_dev *rdev) ERR_PTR(err)); } + rdev->coupling_desc.n_coupled = 0; kfree(rdev->coupling_desc.coupled_rdevs); rdev->coupling_desc.coupled_rdevs = NULL; } -- 2.39.5