From patchwork Mon Dec 19 03:37:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li zeming X-Patchwork-Id: 34382 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2185072wrn; Sun, 18 Dec 2022 20:13:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nQgVHhJEljNMac10a/JpDC9O+AmthtzxHXmYYcidBbO/OTo6ZZU2iwklSwW3wjyz97XDD X-Received: by 2002:a17:906:c2d0:b0:7c1:37:6d5e with SMTP id ch16-20020a170906c2d000b007c100376d5emr34636222ejb.2.1671423196301; Sun, 18 Dec 2022 20:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671423196; cv=none; d=google.com; s=arc-20160816; b=WjSLseouITTx24syIOWiMqNffhBTywTs5ntZ5ylUWFebM89q9oeTlLpcMVJyDLzfzB 6/2XYAQWCsldvQTnZWv3fn1SFzAH5p/BJlkM/xILXJwErJONEfTMu2BESyDCsjnNaGs+ IbrYTxpsePEm28WtHmecJbhG/6cUwv8jYPLB6NrwawmJ84Oqf39GalyNDfHayrLcoZP5 2+s7kdwhGO6jOKHlIf07YUlwl4YsUCMG7LZU7VjpsDeRIGouqPX5ZieCr0Fblv6ODtF6 fbUc1QdWaDSvpyxsuXllJrxdX4Hk0bG3FvE56VVzSKevoQu5lH91o9VTxa4JgBZFMDAi XueQ== 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 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.12.48; Sun, 18 Dec 2022 20:13:16 -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 + 99 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752614249704916076?= X-GMAIL-MSGID: =?utf-8?q?1752614249704916076?= 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, "|");