Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6839379rwl; Mon, 9 Jan 2023 13:53:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXi25x5J7A8fesfLm+jphq0LZ1NMQZeqBgxykwDlDRzwkQQMecmLAhN2ijwwPvFNr0xIF2 X-Received: by 2002:a17:90a:178e:b0:227:1ae2:ec80 with SMTP id q14-20020a17090a178e00b002271ae2ec80mr4157587pja.17.1673301189031; Mon, 09 Jan 2023 13:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673301189; cv=none; d=google.com; s=arc-20160816; b=QQcDULTvxfZc6wx1oDwX2ObHSAJFmasBGcYjVZKxKlQ863Cw2rdGbke64XDkW/kB93 nLZOsXiM+IJjbLFKkOhhc+7OgDSByhmr1HpPjP8deWwF/3XUrEK2qGsRL2dAjlK/swdI zOXskP0wndH5w0LjOFnMX8UxYT1eNIzpn+JoYiLwvgBqn2+/nk3S8Mue+vhmDvyIUFVL uwJcfaZxhy+2Np+2zQF2v/Y5rsXRgCBrFayrsxV3VJPh5KUZd3sprwSWUKa/013EAmx/ 0jfA98m81rRrcFBORK0WDvudFEE6eiEWch+5rrKP6yIChQHXU8DRuEy4DI337duHKsjz qkFQ== 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=6yaSXm/5UdUli4RSuxgorAqCzDHvw4QeW6ySIthbD/8=; b=yNOfPfxjC4S+kt8LW7Oi6ybvPTme57LZQFQmaq93nR1IKDRnOzv/PJY/bXfI8BkWuU khEzB4uhIXLQ+oO6T3A0p0+LrXgldkWn68Yui5aT4VHwh0cz0O/UVf+2KCe9tUaGkdnL Qq/cpnxcAwwII+Ff4FTQmcs0TlXyPpF/Pw4aAVfLWEluWpJ1FO242kwCjZO7xd7MnPBz 3JDk5MPF04mt2gtyDRsde84aclaeBUyG6m2Vb+Gl0jvZVAoXzqbcjOuC0cmNwD6yV7Nx jrxAacW7vzNDtLswm0rh5n43FWqfrQBtw84WQCXhXOmy4NEeaCh7NoTDRO3B75bKJ1gA P46w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UxhOU5xB; 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 r5-20020a17090aad0500b002269d428c01si13454657pjq.70.2023.01.09.13.53.02; Mon, 09 Jan 2023 13:53:09 -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=UxhOU5xB; 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 S238014AbjAIVYs (ORCPT + 55 others); Mon, 9 Jan 2023 16:24:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237837AbjAIVYX (ORCPT ); Mon, 9 Jan 2023 16:24:23 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098F7120B8; Mon, 9 Jan 2023 13:22:45 -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) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 790DE6602D68; Mon, 9 Jan 2023 21:22:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1673299364; bh=ruDrM/DvJP4nnGR4ZDtqvKWlRdT0B6gOft+fqB0NEOA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UxhOU5xBu5ijuzxFAl8iFSnPR5KyT/eR2y858SCbbUAVp3yWP/c1M6SbVJi+7++X8 hHc76Lh+ZAdS9IGcx5lpfX4UEl2dQ5ckMc5K/qhnOtf9P/PopUAQTPBX1OiqTYXt7a dCuSQSAPcQ7lbiqHSQWs1+5UJZu+yNTILBV0fXKeZljsehEAb96Jm0hH94+CY82dhd HmrzNWJlM6g8Kik9XQQi8HUWoFiMHNHkXJzQa4OLe6U3LmftodaT5RGy8gmiGtKTgE bcPd9KEkB1rBNMKe4SchN4nPGp6L2ej7EdJ8jUhBX+m3PbAJtm7vb6lPHWaTvXUAv/ MbR7inZ8DDfTA== Message-ID: <31940cd3086bc6e40f3eb9c7b923dd38131d37dd.camel@collabora.com> Subject: Re: [PATCH] drivers/media/v4l2-core/v4l2-h264.c : 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:22:33 -0500 In-Reply-To: <20221226061711.3988-1-chuanjian@nfschina.com> References: <20221226061711.3988-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 Hi, Le lundi 26 d=C3=A9cembre 2022 =C3=A0 14:17 +0800, Dong Chuanjian a =C3=A9c= rit=C2=A0: > Continue the program when the pointer assignment is successful. >=20 > Signed-off-by: Dong Chuanjian >=20 > diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-cor= e/v4l2-h264.c > index 72bd64f65198..1163cd48ff33 100644 > --- a/drivers/media/v4l2-core/v4l2-h264.c > +++ b/drivers/media/v4l2-core/v4l2-h264.c > @@ -343,18 +343,19 @@ static const char *format_ref_list_b(const struct v= 4l2_h264_reflist_builder *bui > int n =3D 0, i; > =20 > *out_str =3D kmalloc(tmp_str_size, GFP_KERNEL); Can't this patch be reduced to this ? + if (!*out_str) + return NULL; >=20 >=20 > - > - n +=3D snprintf(*out_str + n, tmp_str_size - n, "|"); > - > - for (i =3D 0; i < builder->num_valid; i++) { > - int frame_num =3D builder->refs[reflist[i].index].frame_num; > - u32 poc =3D v4l2_h264_get_poc(builder, reflist + i); > - bool longterm =3D builder->refs[reflist[i].index].longterm; > - > - n +=3D scnprintf(*out_str + n, tmp_str_size - n, "%i%c%c|", > - longterm ? frame_num : poc, > - longterm ? 'l' : 's', > - ref_type_to_char(reflist[i].fields)); > + if (*out_str !=3D NULL) { > + n +=3D snprintf(*out_str + n, tmp_str_size - n, "|"); > + > + for (i =3D 0; i < builder->num_valid; i++) { > + int frame_num =3D builder->refs[reflist[i].index].frame_num; > + u32 poc =3D v4l2_h264_get_poc(builder, reflist + i); > + bool longterm =3D builder->refs[reflist[i].index].longterm; > + > + n +=3D scnprintf(*out_str + n, tmp_str_size - n, "%i%c%c|", > + longterm ? frame_num : poc, > + longterm ? 'l' : 's', > + ref_type_to_char(reflist[i].fields)); > + } > } > =20 > return *out_str;