Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5489744pxb; Mon, 7 Feb 2022 03:17:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwg2rupWttVT4eZVuVySK/m2U1I4haaT/nVgL1/d+ZE5nOIFrVsVDetiFbIOwWGnEhcRulP X-Received: by 2002:a17:906:ad8e:: with SMTP id la14mr2865636ejb.492.1644232632844; Mon, 07 Feb 2022 03:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644232632; cv=none; d=google.com; s=arc-20160816; b=S+L6qDCA6lftbeZCCSRz7AB2O3hk6zkqzEzXCuh6Mfp9AyRL+5UnVfbzkABkGkmmK9 z+fl2JZdlsgq7dZ7Fv1N0UVcCVHc85ledPsi9ZKzXTqpSlUEHZ0pg8zktf/YAp9Lz9Ys Ulf/Dhlsuy5Rayatw5SIupJ25XQ1YJkd4mjpYEzjIZxrM7l0umpET7HWQwDywhwSBm+S FvgQiFF/jmlLDFieEwI1bPgzWlvBFrQXsyuiuGF4zk4w3WQSUCHyLGZKM/sSxa/xlY7a 94Tximv6QX8VHma3tHM7mwOSZx3wGN5LY8/NMiOJYhqr3WMEDqOP99VYgaMcuW3Ikw2f xlvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:organization:references:in-reply-to :message-id:subject:cc:to:from:date; bh=+t7rtyeUuG+uL+WMgZ+wbjT3BWrzyy3oQzcuCkjKYnI=; b=M7v3/NgsQu27t38v/D9Ru3ZkxbZXUKPet0Ys8l1Pw9MzAFnROlymFal1wAGhG6Wooo Ef8YzW1safyedSzK3XGKPpov/H5iwZvTdhvx5BaSOIekAUodpgGzj4CuqtFmEdXJtCRk 7bE4RKbEwUQxq+qfPS4JBYbgiZFUc4/FmHOEFydT3eM/tNw43ZBx2k8fjF6RmQ9FYEPA aYYaMs7daFoIgBorthOQ6aIpCX75rLVQzDFI8ZLBNqkoiOZmUxPfHpz8gtixbv25CWhK nME+BiSvUPUXZlyWBaQ8uHAEKoCwbeegowA0uR/cWAk4k1x/Bq8BKSKew9AEdLTvOiCo N92A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg35si7541742ejc.307.2022.02.07.03.16.47; Mon, 07 Feb 2022 03:17:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356423AbiBEHwQ (ORCPT + 99 others); Sat, 5 Feb 2022 02:52:16 -0500 Received: from comms.puri.sm ([159.203.221.185]:54694 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiBEHwP (ORCPT ); Sat, 5 Feb 2022 02:52:15 -0500 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 55096DF537; Fri, 4 Feb 2022 23:52:15 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tlEkKNwbwbK6; Fri, 4 Feb 2022 23:52:14 -0800 (PST) Date: Sat, 5 Feb 2022 08:51:51 +0100 From: Dorota Czaplejewicz To: Laurent Pinchart Cc: Alexander Stein , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/8] media: imx: Fail conversion if pixel format not supported Message-ID: <20220205085151.61088d8e.dorota.czaplejewicz@puri.sm> In-Reply-To: References: <20220204121514.2762676-1-alexander.stein@ew.tq-group.com> <20220204121514.2762676-5-alexander.stein@ew.tq-group.com> Organization: Purism MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/GkcT.DU6W1y2u=sTikbv/br"; protocol="application/pgp-signature"; micalg=pgp-sha256 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Sig_/GkcT.DU6W1y2u=sTikbv/br Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Laurent, On Sat, 5 Feb 2022 06:07:37 +0200 Laurent Pinchart wrote: > Hi Alexander and Dorota, >=20 > Thank you for the patch. >=20 > On Fri, Feb 04, 2022 at 01:15:10PM +0100, Alexander Stein wrote: > > From: Dorota Czaplejewicz > >=20 > > imx_media_find_mbus_format has NULL as a valid return value, > > therefore the caller should take it into account. > >=20 > > Signed-off-by: Dorota Czaplejewicz > > Signed-off-by: Alexander Stein > > --- > > drivers/staging/media/imx/imx-media-utils.c | 3 +++ > > 1 file changed, 3 insertions(+) > >=20 > > diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/stag= ing/media/imx/imx-media-utils.c > > index 32aaa2e81bea..e0a256a08c3b 100644 > > --- a/drivers/staging/media/imx/imx-media-utils.c > > +++ b/drivers/staging/media/imx/imx-media-utils.c > > @@ -544,6 +544,9 @@ static int imx56_media_mbus_fmt_to_pix_fmt(struct v= 4l2_pix_format *pix, > > cc =3D imx_media_find_mbus_format(code, PIXFMT_SEL_YUV); =20 >=20 > The code passed to the function comes from the previous line: >=20 > imx_media_enum_mbus_formats(&code, 0, PIXFMT_SEL_YUV); >=20 > As far as I can tell, this is guaranteed to return a code that will > result in imx_media_find_mbus_format() returning a non-NULL pointer. >=20 While I am not well-versed in the implicit code style of the kernel, I deci= ded to leave it in because it makes the code more locally legible. With a c= heck here, even a non-functional one, there's no need to understand the int= ernals of `imx_media_find_mbus_format` that are only implicit. That makes t= he code less surprising when interested only in the outer function. The other advantage of a check is becoming robust against future changes to= `imx_media_find_mbus_format` itself. I don't have a strong preference about keeping or leaving this patch, but i= f this check was there in the first place, I wouldn't have spent time tryin= g to figure out whether there's a bug here. Cheers, Dorota > > } > > =20 > > + if (!cc) > > + return -EINVAL; > > + > > /* Round up width for minimum burst size */ > > width =3D round_up(mbus->width, 8); > > =20 >=20 --Sig_/GkcT.DU6W1y2u=sTikbv/br Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEExKRqtqfFqmh+lu1oADBpX4S8ZncFAmH+LJcACgkQADBpX4S8 ZneVXA/8DT1/SWdTKX0nPQztfkSCXSKeoUukY7pJTyrUtwwlGHpsm80yXzEKUIp1 5UpRjrLjStkvHVaP0ZN4FD3pp4k1F2jo/90J1BJuAyfyvwaEdd6rDe5xwnHGyO4M EOidAwrOJMqSwB1z4SGvdG75T/RhDaG8YsS4kXXjkdKqZH8HjySD/t4Eqp1PLlUR XnZDgzWGIOpXXQ1/46S1Pa4DnL2wmC/ZthojOta28k7myyfG40/p0hXPCDaf0DCF j6i3woxvGWf6dBR1txjWnFs8xDhuostpcwvDoEILE9Q97xsApFilVVbWPjZ/9Of4 yOo1zUkbCPx8vqeA+1RLnUj+5xqmeAaF7Xyu2WQdCDCwXzr03gRUWPn9ualPBQlu O8ZI0e+AcM6OIduBF1266sKZoQNy4I68zdDkzO0+ON7qw2uHidGgxH5fjIPXtmwm S+jMZn0Kxse/hrQHLXUyFvJdCPNg2u4xDPELbN69oTql8M9HIF0dfe9oafpQb2/0 XNMEQyeADvxUnf7bSRz6UDGBtmTzygkW2yXoi63EBkGakM6Ry4Ogr8scNes3vFeA Nw0vf8FL3i9TKjpKZimy+LwqzwJSYyAJ06dv6ugVSS7m8hRS3WyAYOH6+BF4Vizq Ptnp9ouFuj2rlb9l4ZCng+mErM95SdciJfZ9CnUJddBQyAyg5mc= =ygHY -----END PGP SIGNATURE----- --Sig_/GkcT.DU6W1y2u=sTikbv/br--