Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2156151rwj; Sun, 18 Dec 2022 23:57:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BBmGGMy0pu3qFUp0ZyODKdSEmJEHoiCfhZYsVBXpnagUMEnypCs1PRrcol9a4l3JB0AkC X-Received: by 2002:a05:6402:3788:b0:467:481f:df5e with SMTP id et8-20020a056402378800b00467481fdf5emr32976206edb.19.1671436639754; Sun, 18 Dec 2022 23:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671436639; cv=none; d=google.com; s=arc-20160816; b=AAz/IpiC8Pu6X8koWNan5ptjVmeRGxS++RGrriJ7K5HaNjF6+3MeqlmgDL9AkJoJrp BKl0rC9p2IaNea1hVyAPdvbkuHcOq6UDukyjAKIua+3yVnwtRt+z8M8cHJVVqvynTeH8 AX1krQMsnQ1TQZEC/Wh6Ru+fTfS4bosNQZxcRtRrt8Lo/+lp66k8GCOoyz6siHiJCedq pVTwV/2xWFQzBbzZdW4RkOcv9fsi8Hst9A3rK1KkwwbbioJpeCHfWsRuvbSLKXmvRUuF b2MR49Uki5b+3i4aVJDFc2I3s1rq+EpMnhtv57vdJy5GRH1xEkmU9OnSzxsKTX24V1b9 KKPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZQXRyu6a6hdNWFaFM+lIaXBcIgFQDwtpyt8WeRchEz4=; b=bMlWoGHTZ5sR5ykCDyu9lFQ6u0WoxfOUQnrPKJV5VufuVyeNXNB1yK9/KC8z0Y0txe qD+l2GGLWpoNGymoqQc74A2jVBYchWm3P2OjkG4fSYNN+fs9zdDa2zDuEvxpIUvy/EYq xZ0wKAk0uC2fAiWet27ab6Om8yjn4NSwICudEEvJVHZzXLui9QKcClaBNdqkCtk878ob wltvxFhB4yuqeONFy0cAVg3e7mkwoxuJEcZNYY4yidpS6L9qV78RxIjyZ3aJiRCW5A0s IkQUEwtm3JjNJlYZ6Peg5ToOYxeo8a+xYZELfGuzoXCvGXqkEc+g3SHNva5AL42JVxop WEXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=olsK2Uwf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a056402191200b0047039339346si10296685edz.550.2022.12.18.23.57.03; Sun, 18 Dec 2022 23:57:19 -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=@gmail.com header.s=20210112 header.b=olsK2Uwf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbiLSHlT (ORCPT + 70 others); Mon, 19 Dec 2022 02:41:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbiLSHlQ (ORCPT ); Mon, 19 Dec 2022 02:41:16 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F7E32AC1; Sun, 18 Dec 2022 23:41:12 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so12112540pjr.3; Sun, 18 Dec 2022 23:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZQXRyu6a6hdNWFaFM+lIaXBcIgFQDwtpyt8WeRchEz4=; b=olsK2UwfYzqPUKl+35ZdgZ6KcfrBuV5sAMP3WI8UpF9uZK6k18enKS0+gIulldpCyZ ipmjptU7vA/K4c5Zs/leYH0BgIwqvdtlVSds0md4cvbU9bfmUluSawoDJ2uByg8Hapdk oY91fcTzc55YDFwKOMNXa69hvipHyBBI5tTzFBsvUr00tDcPYTii7fPvIBEwRFtZnyFC UycYxdZDfztAsyRNTrlsNbcGHV80QYf3KUbfgkd8B83KNPxM0jGFS9Zilwk0H8NDCtu7 M+6hr69Qk8vrsfP7efc24PwO+G2ZDH20AgHeWcEonFljEkvDIh/M07EQlu8YvPKxvcS5 +nNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZQXRyu6a6hdNWFaFM+lIaXBcIgFQDwtpyt8WeRchEz4=; b=aAFtX2QfOiQfTO1JKE02+1uxhxmddutU7Sm+DSyYNrlV4CZRvYCStMS1c9dxfGtuvX LUdl3vWBUHWZyanHXKXELuZMwOR9VfMu3zRIRnPgQ2HEXfSlrOjGOTGHOInvI95NDIRY 0dAWP8OCHvRZYxVldOsfLCs+BjlFFIJ0ZXwrTsesBNvtcB4VwcY4pE1l215n1khAzsrM NyO38c1q/IFlUduaeIBO7utuErvv9PKnJcmQqOutssI9aU9dS9fFcZUmBa5wsrUduGfP lSVNVWEGMObH09QilyucAvvhU9597qjRzJIao506co6lRx+PZKVLv4rIJLtkf6UoAVLU syIA== X-Gm-Message-State: AFqh2kpx7eZruOVsAf4yT8+jdxQvKrtd3f2XiDCIuW86ZYVSgYb9Jgih lplVdgdwoX6hVQFfWGSOOoU= X-Received: by 2002:a17:90b:2747:b0:223:7513:adfd with SMTP id qi7-20020a17090b274700b002237513adfdmr15238189pjb.3.1671435671812; Sun, 18 Dec 2022 23:41:11 -0800 (PST) Received: from debian.me (subs02-180-214-232-26.three.co.id. [180.214.232.26]) by smtp.gmail.com with ESMTPSA id a23-20020a656417000000b0046ae5cfc3d5sm1376812pgv.61.2022.12.18.23.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 23:41:11 -0800 (PST) Received: by debian.me (Postfix, from userid 1000) id DC09A10016D; Mon, 19 Dec 2022 14:41:07 +0700 (WIB) Date: Mon, 19 Dec 2022 14:41:07 +0700 From: Bagas Sanjaya To: Li zeming , mchehab@kernel.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation Message-ID: References: <20221219033712.3270-1-zeming@nfschina.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pKLsL9cNsnMmaJug" Content-Disposition: inline In-Reply-To: <20221219033712.3270-1-zeming@nfschina.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --pKLsL9cNsnMmaJug Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 19, 2022 at 11:37:12AM +0800, Li zeming wrote: > The pointer *out_str adds judgment and should help with program robustnes= s. >=20 Terminology: if[-else] blocks are conditionals, not judgements. > diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-cor= e/v4l2-h264.c > index 72bd64f65198..934aba539332 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) > + return NULL; Why did you add the check beside robustness? Thanks.=20 --=20 An old man doll... just what I always wanted! - Clara --pKLsL9cNsnMmaJug Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQSSYQ6Cy7oyFNCHrUH2uYlJVVFOowUCY6AViwAKCRD2uYlJVVFO o/t0AQCwcopw+TXZljE09jvLgDqqoeetJNthp3jE/EGMTsGsPgD/cBHqoyPpfbBn ULgc5x/oOTjP9V3QOu9umw36f75TIAM= =wTM6 -----END PGP SIGNATURE----- --pKLsL9cNsnMmaJug--