Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1474568rwl; Sun, 25 Dec 2022 23:08:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtoByxUbZS/bv6LjGX0z9sXprGgflx70yvozuHVrWEwZZrPK7VAx73KKMtl94Ox/ay6h+yt X-Received: by 2002:aa7:d0d4:0:b0:461:ed76:cb45 with SMTP id u20-20020aa7d0d4000000b00461ed76cb45mr14677347edo.24.1672038487060; Sun, 25 Dec 2022 23:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672038487; cv=none; d=google.com; s=arc-20160816; b=U5zROnF+cQmhKvzBRy3r0gJU1vqLbUSqm+nUuTMdxQ7YCpSM30OCc1uXCcHqsgE1Rb /+lwCD+ERUL2aWY7jglQ/Kmftoc1NsdnUQxPf475iDf5sXO75tTRHoxpw4KbZxj1WvAY WHyOxiX1Mux+t8bxLlWqcgKaCvJtJ1YkXhd7FEx2WEaZs6Z9PimQoUpW9TdND/V+cKt+ ON6ZeccVyv+HCYu5l72yn9j+AxFcwmGCKbi6u0xufHePBBy9a4oIDpFZz/VCp/XoKy1Z 5vVs8CVoSig/9+FHpAqj7xFEs9AjP+0MEQcKLjl4c2sutKDMVLBjyQF+fczF3RIW9wk/ upDw== 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=0yCm7fdUgmpplRIztQmkFaVseVib1ONHrSe8o7Ns4ho=; b=krcQZQZL11x+VruMJntEGLf4S4XruHf/V6LJaQvlNEDfN9LC/9GImIQiF5IrpcRemv TZrmLNXWJgFMUr7XU2iX9/4D0sFsOAqftqTRAccL5rcHOlY737WWu5SmtUVqLxz4XjIv 6PQrm5nVeHl7F1NZxgicsAqNSlWXG7F9Bkd/mw6bgY9UpUEfGxbYb0XnY1QnpYqnTgcd atv0XccHhSuql/Y19g4lokJIYaMDTRdw8rleuc9GZJrnZVYK8f0RLDH60zCr/PXkqpcj cg0mkm1bHn/l7KXSivw+uchJCXmWuzBOeZbcPg/MVxKiCpG4qAwr9YqQdEv9D2bF2WKN m9Rw== 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 dk25-20020a0564021d9900b00484a42c8233si2172839edb.444.2022.12.25.23.07.51; Sun, 25 Dec 2022 23:08:07 -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 S229999AbiLZGRW (ORCPT + 66 others); Mon, 26 Dec 2022 01:17:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbiLZGRV (ORCPT ); Mon, 26 Dec 2022 01:17:21 -0500 Received: from mail.nfschina.com (unknown [42.101.60.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB48BD44; Sun, 25 Dec 2022 22:17:17 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id E97D21A0091E; Mon, 26 Dec 2022 14:17:20 +0800 (CST) X-Virus-Scanned: amavisd-new at nfs.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i3XE_Magtkvy; Mon, 26 Dec 2022 14:17:20 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: chuanjian@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id D9AFF1A00912; Mon, 26 Dec 2022 14:17:19 +0800 (CST) From: Dong Chuanjian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, sebastian.fricke@collabora.com, ezequiel@vanguardiasur.com.ar Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dong Chuanjian Subject: [PATCH] drivers/media/v4l2-core/v4l2-h264.c : add detection of null pointers Date: Mon, 26 Dec 2022 14:17:11 +0800 Message-Id: <20221226061711.3988-1-chuanjian@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NONE 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 Continue the program when the pointer assignment is successful. Signed-off-by: Dong Chuanjian diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/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 v4l2_h264_reflist_builder *bui int n = 0, i; *out_str = kmalloc(tmp_str_size, GFP_KERNEL); - - n += snprintf(*out_str + n, tmp_str_size - n, "|"); - - for (i = 0; i < builder->num_valid; i++) { - int frame_num = builder->refs[reflist[i].index].frame_num; - u32 poc = v4l2_h264_get_poc(builder, reflist + i); - bool longterm = builder->refs[reflist[i].index].longterm; - - n += 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 != NULL) { + n += snprintf(*out_str + n, tmp_str_size - n, "|"); + + for (i = 0; i < builder->num_valid; i++) { + int frame_num = builder->refs[reflist[i].index].frame_num; + u32 poc = v4l2_h264_get_poc(builder, reflist + i); + bool longterm = builder->refs[reflist[i].index].longterm; + + n += 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)); + } } return *out_str; -- 2.18.2