From nobody Tue Nov 26 21:34:15 2024 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 64D842071F7; Wed, 16 Oct 2024 10:22:38 +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=1729074158; cv=none; b=kRYF7+b3ouISpDfXa0+rWA36bXjegs7DxEijQFoWt2KteM+nqT/Q+FZ1tTPL5XNvrV77WeWleDfwx6KZMUJUNuXtML9d0Ta83GGQLFxIASkqWKhk4GMx1RFYvLCGFrpGwZTUaa+Mqi+QSZMJzAxqo4M1kLrHXtYxRAaUfhRptWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729074158; c=relaxed/simple; bh=6DCqyEDP1eYPPtQ1JbTV1frxNx/jykhPfGF62FWOYy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=crGuyUg9ubv5+Yx/1PLyHmUXSfY3dZdfrwHAuoURhqh5oW2NWLcyFoXOZxcdRM7fBaT1sfT/k8261K2cbAa4ZzVdsUCJ7uVLM6/aEiWDr97ndiJY3ESTFaXOYzI1/fHrX57V1BxM46xWfwGEP/J+1MVOtxKilr+U7hqVNSbCAh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DqqBdHIf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DqqBdHIf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1CF9C4CED7; Wed, 16 Oct 2024 10:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729074157; bh=6DCqyEDP1eYPPtQ1JbTV1frxNx/jykhPfGF62FWOYy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DqqBdHIfFic7shVPcz1idQtvB8DJggll64d52dgmZn2SepvdNI4jr8U7fu9NBv+bn rIbDjT2IcQ9PN4X1IWdhey7gPKjAZ6KkjqC4L+OnPrY9NECYpVE5pW1qmg06QL1+Vr gZM7SISvdS0JDFJ+8bHytsTgMO9hVKC9axmYzVbmXi7Cwe9yR+O7mYcY3T/mgvC/HE MnU2q98OODBs0ay7Mhiot93GzOZAyzuEarVgWp2QKXsX4e/oFtdvlMxvXt5ow515Of PFq/A7YqZo8BnsvvYxM8rPOI03yY4uQkiMrqFjU1Ha3yMSCQntJQgcZhTJpl1tC22Z mAPMvnhpfywKg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1t11Ap-00000004Yn1-2mf4; Wed, 16 Oct 2024 12:22:35 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , Hans Verkuil , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 10/13] media: adv7604 prevent underflow condition when reporting colorspace Date: Wed, 16 Oct 2024 12:22:26 +0200 Message-ID: <41d12c1afd6571f9cc56c1b920df6ba558d0b927.1729074076.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Currently, adv76xx_log_status() reads some date using io_read() which may return negative values. The current logi doesn't check such errors, causing colorspace to be reported on a wrong way at adv76xx_log_status(). If I/O error happens there, print a different message, instead of reporting bogus messages to userspace. Fixes: 54450f591c99 ("[media] adv7604: driver for the Analog Devices ADV760= 4 video decoder") Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Hans Verkuil --- drivers/media/i2c/adv7604.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 48230d5109f0..272945a878b3 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -2519,10 +2519,10 @@ static int adv76xx_log_status(struct v4l2_subdev *s= d) const struct adv76xx_chip_info *info =3D state->info; struct v4l2_dv_timings timings; struct stdi_readback stdi; - u8 reg_io_0x02 =3D io_read(sd, 0x02); + int ret; + u8 reg_io_0x02; u8 edid_enabled; u8 cable_det; - static const char * const csc_coeff_sel_rb[16] =3D { "bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB", "reserved", "RGB -> YPbPr601", "reserved", "RGB -> YPbPr709", @@ -2621,13 +2621,21 @@ static int adv76xx_log_status(struct v4l2_subdev *s= d) v4l2_info(sd, "-----Color space-----\n"); v4l2_info(sd, "RGB quantization range ctrl: %s\n", rgb_quantization_range_txt[state->rgb_quantization_range]); - v4l2_info(sd, "Input color space: %s\n", - input_color_space_txt[reg_io_0x02 >> 4]); - v4l2_info(sd, "Output color space: %s %s, alt-gamma %s\n", - (reg_io_0x02 & 0x02) ? "RGB" : "YCbCr", - (((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ? - "(16-235)" : "(0-255)", - (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); + + ret =3D io_read(sd, 0x02); + if (ret < 0) { + v4l2_info(sd, "Can't read Input/Output color space\n"); + } else { + reg_io_0x02 =3D ret; + + v4l2_info(sd, "Input color space: %s\n", + input_color_space_txt[reg_io_0x02 >> 4]); + v4l2_info(sd, "Output color space: %s %s, alt-gamma %s\n", + (reg_io_0x02 & 0x02) ? "RGB" : "YCbCr", + (((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ? + "(16-235)" : "(0-255)", + (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); + } v4l2_info(sd, "Color space conversion: %s\n", csc_coeff_sel_rb[cp_read(sd, info->cp_csc) >> 4]); =20 --=20 2.47.0