Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6829920rwl; Mon, 9 Jan 2023 13:43:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzo9rZCrLQkw7icw8Rs3zZ9vzC1eNE+Nogu6Pcns0P8iSD+pKg1KWMh6e/8QMFfa5pM8Z1 X-Received: by 2002:a17:90b:100e:b0:227:1e67:d58f with SMTP id gm14-20020a17090b100e00b002271e67d58fmr3437193pjb.12.1673300611424; Mon, 09 Jan 2023 13:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300611; cv=none; d=google.com; s=arc-20160816; b=i3q+cNm7Q2cMKtTDz6veo+IdCEc5rEAlhTZbI/8n9XWDL8epIPJVVOpRZT3cT8OTKs eqmCRctAZdVG686pSSfkToWEuaOeQ5Jk3e9HV12LnI2vmQFNiewgrjrnYkQNSWCetzrC PQKhfdN9RtkYZd2fTCQWum0MNboahG4TV3CcRM9iOmH6EhpJN21VXE5TebXnqAZfXxqv 6CL2heq8dWhhCXjfouMRj2aPVDg+vA0UBkulTBusNTawLjTAPzKPwmNePOMCskyECYJA D453wEyvccix/LLBYuKZf3im40+jxyJ8gtTs2Yk7IZrlHTWcU9Js5g207vk5DPnf1JHd hqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=sswW7MTZhCb9/kMOqjZGZHAVvNAXXddc5navtL8JIiA=; b=FoQTI3hLMYy6TfcZGrXPyJya6JDuvBThpTDCQxVWqPqm04WnjaaOWRxpxK4XQ4yNqL 5jzo5F5K5S8/Cvq9bKmKZO9bnJhyHFrSnHQ/ZZGr677XBqQcixhhiEC7u4Lz+aoxWbrU cr+UybcObmXfZjrRRO2kpmDstH6QcTwwibQwV6xDT9cSIwbWN4e/cnCnB7UKidzKIciL Nq1yqYUfdwTkX2Fx1UdhtR7etXfIBt3t1tq0ZqwqNuZ0CibfjWG8z+yYZMlrx3i5ivf/ CpNRAJXxu4bgBbC+16iMhjQwO+Efffwp7lpxYMaIJZRmUcLtSIsXGvqrXKi7QH4f0vJ6 1BIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z2/2APEp"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp17-20020a17090b4a9100b002188666feeasi15242932pjb.3.2023.01.09.13.43.24; Mon, 09 Jan 2023 13:43:31 -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; dkim=pass header.i=@collabora.com header.s=mail header.b="Z2/2APEp"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237479AbjAIV1n (ORCPT + 55 others); Mon, 9 Jan 2023 16:27:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbjAIV1l (ORCPT ); Mon, 9 Jan 2023 16:27:41 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5AFF55; Mon, 9 Jan 2023 13:27:40 -0800 (PST) Received: from nicolas-tpx395.localdomain (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id D21446602D68; Mon, 9 Jan 2023 21:27:38 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1673299659; bh=o3DMSt1Ot2XXOL0bLV4Le+gFHG5Qw9UAoA+XB/anXbE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Z2/2APEpGTaq+zXXShUb9nDM4nYcStKcnqYguBnfDgZbaFtXwo8oOBw4EWhFUgIc6 QiP5F7TYoUyWK6bvkqnAJYLnj70+NJuvmLfld4i/8t7IygKvVktK6U9JrCeLXPBjTs n9UOELkStOaZpjHm5hIOhLMnBIpiMvoLTenYVNsRVuzpXV3Ahk330G+uJhuEXF4KI3 MweGdNwQaLtJfBNls6wnTyaGLZIXKMAUaPLjslHpQgnj5XTHj3hUD7ThzGdebviVx8 t1TrSZTeK9IwhU/dH/+SOD/nDehXUbAA4XvRmTmLstcfLVq8wHnWOH4pKUADLj35mg sZHFpl7oL0K3g== Message-ID: <8b408632218fd0f06ec862a51822cf08e0f50a57.camel@collabora.com> Subject: Re: [PATCH] drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers From: Nicolas Dufresne To: Dong Chuanjian , mchehab@kernel.org, hverkuil-cisco@xs4all.nl, sebastian.fricke@collabora.com, ezequiel@vanguardiasur.com.ar Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 09 Jan 2023 16:27:29 -0500 In-Reply-To: <20221227023625.7261-1-chuanjian@nfschina.com> References: <20221227023625.7261-1-chuanjian@nfschina.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.2 (3.46.2-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mardi 27 d=C3=A9cembre 2022 =C3=A0 10:36 +0800, Dong Chuanjian a =C3=A9c= rit=C2=A0: > When the pointer variable is judged to be null, null is returned > directly. >=20 > Signed-off-by: Dong Chuanjian Acked-by: Nicolas Dufresne Please add the missing Fixes tag. Fixes: d3f756ad629b39 ("media: v4l2: Trace calculated p/b0/b1 initial refli= st") If someone have time, the pr_debug should be ported to v4l2_debug according= to some other reviews. > --- > v2: Directly return when pointer allocation fails. > v3: problems in synchronous repair format_ref_list_p >=20 > diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-cor= e/v4l2-h264.c > index 72bd64f65198..f6684c1d7319 100644 > --- a/drivers/media/v4l2-core/v4l2-h264.c > +++ b/drivers/media/v4l2-core/v4l2-h264.c > @@ -305,6 +305,8 @@ static const char *format_ref_list_p(const struct v4l= 2_h264_reflist_builder *bui > int n =3D 0, i; > =20 > *out_str =3D kmalloc(tmp_str_size, GFP_KERNEL); > + if (*out_str =3D=3D NULL) > + return NULL; > =20 > n +=3D snprintf(*out_str + n, tmp_str_size - n, "|"); > =20 > @@ -343,6 +345,8 @@ static const char *format_ref_list_b(const struct v4l= 2_h264_reflist_builder *bui > int n =3D 0, i; > =20 > *out_str =3D kmalloc(tmp_str_size, GFP_KERNEL); > + if (*out_str =3D=3D NULL) > + return NULL; > =20 > n +=3D snprintf(*out_str + n, tmp_str_size - n, "|"); > =20