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 3929F46B9F; Mon, 1 Apr 2024 15:57:43 +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=1711987063; cv=none; b=RTPizuk4JnEIImH3QbPAwTvMefCsyknymFZpviBC9ecUpkmo30c1/0yKebIr+Eq7HltVGskEZ8XS1sSgQg8bfwsWMFt04OK8ESQLyiBjzCDjip7h/8HMYHejvy0TGdVwg7oIxV/1bpNYqI57kx10G/ChRMCuH1RYXWoEsdRC18I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711987063; c=relaxed/simple; bh=vBF/J+RgoH7CmLGMfeFSy+elH0JIdItHVDkhbxw9efk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q2XIud3fcDKRjpQ/EbqYGJOXjMYBP3Ls3yrhFIMVDLz1UTOxQ7EPQHi/boXq6GS8GFgjbuQdvTUvy16rqJAREj3HscfWnjw1tewXSrD8Clfi8+LnqcoFAQ/NycbQKoC0/wOQBh+aGuG4ivqrzdNEIPywsfvz/S9E91YTsfLoD4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OarPpwqp; 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="OarPpwqp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAC2C433C7; Mon, 1 Apr 2024 15:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711987063; bh=vBF/J+RgoH7CmLGMfeFSy+elH0JIdItHVDkhbxw9efk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OarPpwqp21Mvv8EAfUW51k/p9WNY8wZmtZQPIlbbvaTi+kJyHqaNmLdEH36MKcYrc P3TTYQTpNwXnm8NwmIoBzft9TgHQ+Szct8YCtMdgrx1lUW5lMWcC4Adn9phsCG39+d DHxHl+mc59xnipqVjAoBplVzQymVIDB+A/cyWrCA= 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.8 165/399] drm/probe-helper: warn about negative .get_modes() Date: Mon, 1 Apr 2024 17:42:11 +0200 Message-ID: <20240401152554.105933281@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152549.131030308@linuxfoundation.org> References: <20240401152549.131030308@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.8-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 23b4e9a3361d8..744cde9db246b 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -419,6 +419,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 881b03e4dc288..9ed42469540eb 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -898,7 +898,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