From nobody Wed Sep 17 14:04:58 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10BA6C10F1B for ; Mon, 19 Dec 2022 03:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbiLSDhU (ORCPT ); Sun, 18 Dec 2022 22:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiLSDhS (ORCPT ); Sun, 18 Dec 2022 22:37:18 -0500 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D024A471; Sun, 18 Dec 2022 19:37:17 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id E7E571E80D32; Mon, 19 Dec 2022 11:32:19 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hv75G4U5XvoX; Mon, 19 Dec 2022 11:32:17 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 30DAA1E80D6D; Mon, 19 Dec 2022 11:32:17 +0800 (CST) From: Li zeming To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation Date: Mon, 19 Dec 2022 11:37:12 +0800 Message-Id: <20221219033712.3270-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The pointer *out_str adds judgment and should help with program robustness. Signed-off-by: Li zeming --- drivers/media/v4l2-core/v4l2-h264.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/= 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 v4l2_= h264_reflist_builder *bui int n =3D 0, i; =20 *out_str =3D kmalloc(tmp_str_size, GFP_KERNEL); + if (!*out_str) + return NULL; =20 n +=3D snprintf(*out_str + n, tmp_str_size - n, "|"); =20 --=20 2.18.2