From patchwork Sun Aug 4 13:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Lobanov X-Patchwork-Id: 13752663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 197BDC3DA64 for ; Sun, 4 Aug 2024 16:12:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CD6710E056; Sun, 4 Aug 2024 16:12:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=rosalinux.ru header.i=@rosalinux.ru header.b="VlJEH5hA"; dkim-atps=neutral X-Greylist: delayed 569 seconds by postgrey-1.36 at gabe; Sun, 04 Aug 2024 14:08:19 UTC Received: from mail.rosalinux.ru (mail.rosalinux.ru [195.19.76.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA10210E0B8 for ; Sun, 4 Aug 2024 14:08:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 65B60DFA330A7; Sun, 4 Aug 2024 16:58:47 +0300 (MSK) Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id V0CqRZtZYTbG; Sun, 4 Aug 2024 16:58:47 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 2F402DFA330AE; Sun, 4 Aug 2024 16:58:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru 2F402DFA330AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1722779927; bh=darQ1Ny576F9H9QNqgko9qEevQrfo0NSfm0joyfHG88=; h=From:To:Date:Message-ID:MIME-Version; b=VlJEH5hAs5jukBtwUzHSo3H6uNuxR2ONwnh8Oi7KThkafmYXsxWNVh5kKJjxl4lec KB6ubyt2sujZDqjJ8VM2XLYdIOPTvF1gU1SfHEN3qkl747acKReBAU7rNzsm0thjJu OUs2dpABVS7/Mrs2juoDQwSbTMe8hobnBcRVvYJD8u6DN+G6rWxcVfslW5Qub4xv5l BoHImQXDqHXvOhSgAXvHtNG2IJywqHVIxNgfd/HDw0YqNGeqSIpqKJyd3kYNDkQOxi eReSQQUcr/b/Xzge4YS6ca5ub14/Cxp8ukH1kE2uVwRIP4uWicC+HUVpuvRnA69AsS GOocwYTgKjMyA== X-Virus-Scanned: amavisd-new at rosalinux.ru Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1yrFGckKrxEQ; Sun, 4 Aug 2024 16:58:47 +0300 (MSK) Received: from localhost.localdomain (unknown [89.169.48.235]) by mail.rosalinux.ru (Postfix) with ESMTPSA id C7372DFA330A7; Sun, 4 Aug 2024 16:58:46 +0300 (MSK) From: Mikhail Lobanov To: Russell King Cc: Mikhail Lobanov , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jani Nikula , Thierry Reding , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] i2c: Add error handling for drm_hdmi_avi_infoframe_from_display_mode in tda998x_write_avi Date: Sun, 4 Aug 2024 09:57:35 -0400 Message-ID: <20240804135737.62663-1-m.lobanov@rosalinux.ru> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 04 Aug 2024 16:12:49 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch adds error handling for the return value of the drm_hdmi_avi_infoframe_from_display_mode function within the tda998x_write_avi function. The function's return value is checked to ensure that any errors encountered during the generation of the AVI infoframe are properly handled. If the function fails, an error message is logged and the function exits early to avoid further operations with invalid data. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 13d0add333af ("drm/edid: Pass connector to AVI infoframe functions") Signed-off-by: Mikhail Lobanov --- drivers/gpu/drm/i2c/tda998x_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index d8d7de18dd65..6d8b3654d9a9 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -860,8 +860,13 @@ tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode { union hdmi_infoframe frame; - drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, + err = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, &priv->connector, mode); + if (err < 0) { + dev_err(&priv->connector.dev, "failed to get AVI infoframe: %d\n", err); + return; + } + frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_FULL; drm_hdmi_avi_infoframe_quant_range(&frame.avi, &priv->connector, mode, priv->rgb_quant_range);