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 D54F24AEDF; Mon, 1 Apr 2024 17:02:48 +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=1711990968; cv=none; b=Hs8qPjduWCXenpf30rdGCNQO0U7SmHUwLJdpERQ6TG1gggqbA5VFEPYr5jE7ZwFMVVctKd+j47/QPf8WSw0WEkauV/8bSTxyTDiSfkCk7lAZ9mdO+CTCVeU/5jPeL4OFKXPoNe3PLQqRPruS67XO3aOtkaI/jo6ECUZvtrRv4M4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711990968; c=relaxed/simple; bh=mswpXEYQptGqWC+z1pZsMbd3OwNXywb1wFCBD+A0N14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YY6CXrpTRLqjw5aOJ9AqYBS7/2uKOruFKbohFeiO4ncZ+V0P1/3ev7E0dTdnXlt49gql2WyYuo0bLtB67H+1i/O2oMl8+PHmoW403mTYqsGYyC6oZCqOlyZkMbqi6BEne4GZE6/pvYNvcEsdGE02qdZNmjxxlGhm2ixzBNdDfqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I9eu2f9S; 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="I9eu2f9S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37A53C433C7; Mon, 1 Apr 2024 17:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711990968; bh=mswpXEYQptGqWC+z1pZsMbd3OwNXywb1wFCBD+A0N14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9eu2f9SD+/j+Xf9nzBHTgx6zoGjBjGWS9niUpj5A1VVYLo1o6aZtDYbEQ/TrFgGy 2gjCvpslR2DfSzhKeXVvjTdsUNUPRB5bmMTUC2NXigiD+i981YUN8kRhmKHx6De0qC AtHp2p1vvbgymWS6jEADYCrCeV3FForRe6B0DVCE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Zimmermann , Jani Nikula , Sasha Levin Subject: [PATCH 6.1 115/272] drm/probe-helper: warn about negative .get_modes() Date: Mon, 1 Apr 2024 17:45:05 +0200 Message-ID: <20240401152534.249981702@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152530.237785232@linuxfoundation.org> References: <20240401152530.237785232@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: Jani Nikula [ Upstream commit 7af03e688792293ba33149fb8df619a8dff90e80 ] The .get_modes() callback is supposed to return the number of modes, never a negative error code. If a negative value is returned, it'll just be interpreted as a negative count, and added to previous calculations. Document the rules, but handle the negative values gracefully with an error message. Cc: stable@vger.kernel.org Acked-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/50208c866facc33226a3c77b82bb96aeef8ef310.1709913674.git.jani.nikula@intel.com Signed-off-by: Jani Nikula Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_probe_helper.c | 7 +++++++ include/drm/drm_modeset_helper_vtables.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 3b968ad187cf3..52dbaf74fe164 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -362,6 +362,13 @@ static int drm_helper_probe_get_modes(struct drm_connector *connector) count = connector_funcs->get_modes(connector); + /* The .get_modes() callback should not return negative values. */ + if (count < 0) { + drm_err(connector->dev, ".get_modes() returned %pe\n", + ERR_PTR(count)); + count = 0; + } + /* * Fallback for when DDC probe failed in drm_get_edid() and thus skipped * override/firmware EDID. diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index fafa70ac1337f..6f19cf5c210e5 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -896,7 +896,8 @@ struct drm_connector_helper_funcs { * * RETURNS: * - * The number of modes added by calling drm_mode_probed_add(). + * The number of modes added by calling drm_mode_probed_add(). Return 0 + * on failures (no modes) instead of negative error codes. */ int (*get_modes)(struct drm_connector *connector); -- 2.43.0