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 84BB7481B8; Mon, 1 Apr 2024 16:42: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=1711989763; cv=none; b=RcKzbMWhDIvDchKd9u1D9K/xsR6yjVjryTmy1IrpwrPaSMWqOR6NnHF0M1W5Xc3QGVH1A8oRh41Zzuv1W+LrBQACNPABLU5ftFr9hYfTgA27F06S+cJkqKai3LlQ3g0puL9NNBUaqtXUW53fE2HMgYoZDpvH5R2+OUmgvmZcJKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989763; c=relaxed/simple; bh=voUdliA5hMHKoTLZ3sa0BBg/eHwkdpBfIH5DrrxODMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fN07zUjcMMQGjx+zkJH3kM7ECJI7Lg/jSpyyCJVlfpL8Uo+NiogVZWcAwokHoYTVX0kB/Xo8yn4+F9Am9YhMz44xUmwqfpGhlEG6EDSHfk3sr5BzhYUzckKVMlTB7W93XtFqjwGM3q4Z+lfATl3p1SrKpIT1lo85HzLQ1gPQ/H4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NuYrc6ZH; 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="NuYrc6ZH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBA6AC433F1; Mon, 1 Apr 2024 16:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711989763; bh=voUdliA5hMHKoTLZ3sa0BBg/eHwkdpBfIH5DrrxODMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuYrc6ZHlMbIPjFM2QwdW1efkfLCGlUFCyBr7wKrn9oLWFGI3dwCk/5GxMugGD1xC Ulj9fro3C0iKVLidO/gIZU/9Q+t4UQ5dO62LrA37jYjA3JhsxpfodYqNkg/jRNs8hA 87odc7/ByIuQSU8FSORluePgLrlxfDK5QQAAMcLc= 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.6 145/396] drm/probe-helper: warn about negative .get_modes() Date: Mon, 1 Apr 2024 17:43:14 +0200 Message-ID: <20240401152552.269450433@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152547.867452742@linuxfoundation.org> References: <20240401152547.867452742@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.6-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 3f479483d7d80..15ed974bcb988 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 e3c3ac6159094..159213786e6e1 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