From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BC64606A329 for ; Mon, 30 Nov 2026 11:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B1Ykk96W Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBADC10EF2B; Mon, 30 Nov 2026 11:55:44 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 804F710EF2B for ; Mon, 30 Nov 2026 11:53:50 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 04FCA61EFD; Mon, 30 Nov 2026 11:53:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D6C61F00897; Mon, 30 Nov 2026 11:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796039629; bh=YrLW5cDvWYWe9GvzpmnWfvo1nA9QYMnyB4zqX5S+B6s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=B1Ykk96WLFjECf7At67eBIqcrlTyog8lA3TgdEWyJdQGu0qengt70RcOjbcTKqXRM mrcQA1BzfeykL1oh2j+Fb7ySxBES/0yIk6OUQyyrpJtlegI0+IXvzU841DNdzWhTsq k4HOw6W+b6mfdx4PZFGrwIID8f9j3JBqM8MoefHyg3b0OM4+EAKc1Q1rHP9E3AYbRx miF8SRYR7WQQ8lOHYojzrE+i6/lYUHslAQRrQWAxfZYoAR0D4Tvq6RH6BKAPg4crJB +3PhP44+EvFHd/FvFdA15hDxBlwA+VY4gnmeKJWEMgDuZ5iZBuIeh7uaZgVIT/+wWK meVWxGmTsM5lg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v9 09/13] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs To: "Svyatoslav Ryhel" Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261130114155.72920-10-clamor95@gmail.com> References: <20261130114155.72920-1-clamor95@gmail.com> <20261130114155.72920-10-clamor95@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 11:53:48 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/tegra: NULL dereference from new state lookup in atomic_disable() - [Low] drm/tegra: redundant tegra_dsi_get_state() in tegra_dsi_encoder_enable() -- commit 74ebbfecbca273aa0938d93154bb9f25f3ba63aa Author: Svyatoslav Ryhel drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs This commit converts the Tegra DSI, HDMI, RGB, and SOR encoder helpers from the legacy enable() and disable() callbacks to atomic_enable() and atomic_disable(). > diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c > index 6d6adc485e51e..dd3fc09f57487 100644 > --- a/drivers/gpu/drm/tegra/dsi.c > +++ b/drivers/gpu/drm/tegra/dsi.c [ ... ] > @@ -855,14 +863,21 @@ static void tegra_dsi_unprepare(struct tegra_dsi *d= si) > dev_err(dsi->dev, "failed to suspend: %d\n", err); > } > =20 > -static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) > +static void tegra_dsi_encoder_disable(struct drm_encoder *encoder, > + struct drm_atomic_commit *comm_state) > { > struct tegra_output *output =3D encoder_to_output(encoder); > - struct tegra_dc *dc =3D to_tegra_dc(encoder->crtc); > struct tegra_dsi *dsi =3D to_dsi(output); > + struct drm_connector_state *conn_state; > + struct drm_connector *connector; > + struct tegra_dc *dc; > u32 value; > int err; > =20 > + connector =3D drm_atomic_get_new_connector_for_encoder(comm_state, enco= der); > + conn_state =3D drm_atomic_get_new_connector_state(comm_state, connector= ); > + dc =3D to_tegra_dc(conn_state->crtc); [Severity: High] Does looking up the new connector state in atomic_disable() cause a NULL pointer dereference when disabling an output? When an output is disabled, update_connector_routing() clears new_conn_state->best_encoder to NULL before the commit phase runs atomic_disable(). drm_atomic_get_new_connector_for_encoder() then returns NULL, and drm_atomic_get_new_connector_state() dereferences connector->inde= x. Even if the connector were being moved to another CRTC, the new state would point to the new CRTC rather than the old CRTC that was driving this encode= r. The same regression is present in tegra_hdmi_encoder_disable(), tegra_sor_hdmi_disable(), and tegra_sor_dp_disable(). These disable callbacks should query the old state via drm_atomic_get_old_connector_for_encoder() and drm_atomic_get_old_connector_state() (or drm_atomic_get_old_crtc_for_encode= r()). > @@ -919,16 +934,26 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi) > return 0; > } > =20 > -static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) > +static void tegra_dsi_encoder_enable(struct drm_encoder *encoder, > + struct drm_atomic_commit *comm_state) > { > - struct drm_display_mode *mode =3D &encoder->crtc->state->adjusted_mode; > struct tegra_output *output =3D encoder_to_output(encoder); > - struct tegra_dc *dc =3D to_tegra_dc(encoder->crtc); > struct tegra_dsi *dsi =3D to_dsi(output); > + struct drm_connector_state *conn_state; > + struct drm_crtc_state *crtc_state; > + struct drm_connector *connector; > struct tegra_dsi_state *state; > + struct drm_display_mode *mode; > + struct tegra_dc *dc; > u32 value; > int err; > =20 > + connector =3D drm_atomic_get_new_connector_for_encoder(comm_state, enco= der); > + conn_state =3D drm_atomic_get_new_connector_state(comm_state, connector= ); > + crtc_state =3D drm_atomic_get_new_crtc_state(comm_state, conn_state->cr= tc); > + dc =3D to_tegra_dc(conn_state->crtc); > + mode =3D &crtc_state->adjusted_mode; > + > err =3D tegra_dsi_prepare(dsi); > if (err < 0) { > dev_err(dsi->dev, "failed to prepare: %d\n", err); > @@ -944,7 +969,7 @@ static void tegra_dsi_encoder_enable(struct drm_encod= er *encoder) > if (value & DSI_POWER_CONTROL_ENABLE) > tegra_dsi_disable(dsi); > =20 > - state =3D tegra_dsi_get_state(dsi); > + state =3D tegra_dsi_get_state(dsi, comm_state); > =20 > tegra_dsi_set_timeout(dsi, state->bclk, state->vrefresh); > =20 > @@ -957,7 +982,7 @@ static void tegra_dsi_encoder_enable(struct drm_encod= er *encoder) > if (output->panel) > drm_panel_prepare(output->panel); > =20 > - tegra_dsi_configure(dsi, dc->pipe, mode); > + tegra_dsi_configure(dsi, dc->pipe, mode, comm_state); [Severity: Low] As reported by Mikko Perttunen on v8 [1], since tegra_dsi_encoder_enable() already retrieves conn_state via drm_atomic_get_new_connector_state(), can = it use to_dsi_state(conn_state) directly and pass struct tegra_dsi_state * into tegra_dsi_configure() so tegra_dsi_get_state() can be dropped? [1] https://lore.kernel.org/r/mxfdX1kqQz209wWYqFOofg@nvidia.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130114155.7292= 0-1-clamor95@gmail.com?part=3D9