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 7060F1AC24F; Thu, 6 Jun 2024 14:15:30 +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=1717683330; cv=none; b=q1EpXriznCuIX+Z6dnxffQzqneHnxsODs5TKH4GF4pYZCBztTZFmP/LchqiIf4YOX6CYdq3HU1Rdcq59Tnhwlqw+q0jcf5uAxH4bsVdo7elJ+oLeRaypvSLAc5MLuE05W8+iQWT/5cvYhO+3fUQ2CxPEGbUNjqunrAO3AyiDjes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683330; c=relaxed/simple; bh=XlsqbfZmhN9Vg2qml271kTdrSs97XoH2GfzMokTFK6I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rv99FGz2qhxxInFZndH8O0o6OFIivTcZKGR0w1Whw+bZcLFNMJaY2wDShDwe3AhraJIlmCglTSrZFcfXj9cQNnPtTR/jjbnXgR39mWDNq+jYbD2Dgve1pUCWpM8fEQXLf46FplfXei7WcFjWpLvf8HgumiL1hxP83tjQuaNYUlQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JLVS8y/a; 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="JLVS8y/a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E1A5C2BD10; Thu, 6 Jun 2024 14:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683330; bh=XlsqbfZmhN9Vg2qml271kTdrSs97XoH2GfzMokTFK6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JLVS8y/aXHL3qbBrDMdesSa1d/QwL7T8ELH3HxFsJnL6I7wyXzWUVQiy6sVZN3tMu //b7+Xd5g1qVzrOl/9bz7pE7dPKseWTahIoNmyiJLTn/4DjDaVCXkpFMneRlJY3TBp etxRiNfuqmPWQ7vjQFKYg/DLeukDnDUS2GyuzeQ8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aleksandr Mishin , Robert Foss , Sasha Levin Subject: [PATCH 6.1 212/473] drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference Date: Thu, 6 Jun 2024 16:02:21 +0200 Message-ID: <20240606131706.927607359@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131659.786180261@linuxfoundation.org> References: <20240606131659.786180261@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: Aleksandr Mishin [ Upstream commit 935a92a1c400285545198ca2800a4c6c519c650a ] In cdns_mhdp_atomic_enable(), the return value of drm_mode_duplicate() is assigned to mhdp_state->current_mode, and there is a dereference of it in drm_mode_set_name(), which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Fix this bug add a check of mhdp_state->current_mode. Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge") Signed-off-by: Aleksandr Mishin Reviewed-by: Robert Foss Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/20240408125810.21899-1-amishin@t-argos.ru Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c index 31442a9225029..1b7c14d7c5ee3 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c @@ -2042,6 +2042,9 @@ static void cdns_mhdp_atomic_enable(struct drm_bridge *bridge, mhdp_state = to_cdns_mhdp_bridge_state(new_state); mhdp_state->current_mode = drm_mode_duplicate(bridge->dev, mode); + if (!mhdp_state->current_mode) + return; + drm_mode_set_name(mhdp_state->current_mode); dev_dbg(mhdp->dev, "%s: Enabling mode %s\n", __func__, mode->name); -- 2.43.0