Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1987555rwj; Sun, 18 Dec 2022 20:14:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OnGvGwb4rjIZ0icvMg4UHDKwNciEIFwNMpWdQipQD2Zcy54k29WRbOBlMJMbaKtqthkk+ X-Received: by 2002:a17:906:d8b7:b0:7c4:f752:e959 with SMTP id qc23-20020a170906d8b700b007c4f752e959mr13198378ejb.33.1671423265422; Sun, 18 Dec 2022 20:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671423265; cv=none; d=google.com; s=arc-20160816; b=wqPlGoixnIs+b8DMUor1Cx7SE7lWRqYRJElsJ0xX7nyFlsZbMfVBun0FQ1NXTKVxUB mThpzL3/xauMwcHlPmaJnEEWKMRg8zRz2JneajR80r0Ps2Q6qBFfqcTWlePHAPzfwuvS IVOjOMFQQV41rJXipANe/zoSptGK1a+EOWoivtEax1TAxPnT6n1bN7UQG5e49xmJrkTH E4nBeImv40LWhdLqA4U5/LSAP3Y6kKx1LC2vtiT4GpuyD9JK7kfLm9cYo3ihi4UnPKQ6 L2++gXLP1lQu23xzZodPZdAs7mElDcDNsGmSmDCh+4oQWE50+dbKgPdS0LswttkKNiDW PQCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=LmbvkzvdTQ0cTcrS2VL3l2YeP1oAuqnVzvVzS3+UZgE=; b=r9Wh69Gf2InFbAa/bdZnvk4Rjj8UKpR+Vnt9avX8NoHhuBUMxy5FKP/GH8HaVys/RW z2AyL0d8gNemxrziFtTPvEk6WpaSUbdRgSI1/4zPG8jbF8j61DK4dausRMoHanB5kbfg PwqE/cJrUf+ZOkLrG+yNVFRFWTLxBGVWCkwRR8IYLGoI2LxuFnbeHR0XplSBzhSOZeql r9wFrD40bWeGQ3aQakRt/h4NLq0I3zJ30m6wOadG1f6SDVWw8KUXHNfSzE/7EqPfUpww LbppnG4mrC2zOfCaIboy+Rp13aSzHyXRQxfj09TyhKEwmAO7u52mPhPezwoYonpAbddj GKPQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga27-20020a1709070c1b00b007c0abf0760fsi8917675ejc.54.2022.12.18.20.14.08; Sun, 18 Dec 2022 20:14:25 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbiLSDhU (ORCPT + 70 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 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 = 0, i; *out_str = kmalloc(tmp_str_size, GFP_KERNEL); + if (!*out_str) + return NULL; n += snprintf(*out_str + n, tmp_str_size - n, "|"); -- 2.18.2