Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2623109rwl; Mon, 26 Dec 2022 19:02:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVc6ymu9jGZcq0kc9lWF24jT1Dk4E3g3jFNarsSxcCRDBlI5pm5L9Kbs8JtATYpc6d1ans X-Received: by 2002:a17:902:6845:b0:192:569c:e54c with SMTP id f5-20020a170902684500b00192569ce54cmr17993434pln.53.1672110160804; Mon, 26 Dec 2022 19:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672110160; cv=none; d=google.com; s=arc-20160816; b=dcdKDyVLleHK3iyrJkwZGQDYDEQGWIV7heZPd6NI8ilaRKZ+Y8SoswO30biGQZmAeu 2/87fJfM7wfF/YKfXEsYm4tcrG76DJTvSJD3MlNV+fi/eI8+QT+tXxWZOu2OTe1+nb7o 4CT+/LrpqX7hKek/VJSvl+5RdDpP76RXaMZYdo2C7kZzXUxneE0JSVMNkKZXs572aYig lqDSP/HcqeTEfyu6OgISRaLGdhVKSyjt2oNMbYuLH1e5IAl9AdgpeJBFI0ogJPSGwK4o 5rBvVuziQmyLnwTers2Ag8WZWHc6ifGbMPTX0Lvz6DAI+22PAELxCXFFxEampL+Atsdi 2JUQ== 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=o5J4Ogean0+7X30wrGh1KzgnNolV8cqPazIQq5hFxbQ=; b=yGQHtg6JLaBFuIJ6SjD+eVWEFlR8iYu16RVhNknzlWbVVH+ZKUQTwllfvHxldI4hEv t0nUUj3Q9mciLD2s2sNSX0hMRihfcU3pObaIfVORDd6KqOZIpWE181frPq1NEHEIYQQc qeNZLt46/TZykCYH/X/ISasbzGl9+5pjPhEp5q+tj/caYCjaM4fHmsTh7i3ssmIOjSmF SPH/Lel1KdhYj8WeCbbeMfoSnJ1ZX/dJWgCiJNBI2+wkOWhBgZ/exb+BOgIgxmuhzrZ1 vjXPC/oiQA0M4ywQohqoKKXJ0bMZ4FdEfT98aAvJXB5g/mr8kXsIaoFGZNy18jRtXiVr hnhw== 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 l17-20020a170902f69100b00186c37272a6si604873plg.178.2022.12.26.19.02.31; Mon, 26 Dec 2022 19:02:40 -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 S230492AbiL0Cgr (ORCPT + 66 others); Mon, 26 Dec 2022 21:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbiL0Cgg (ORCPT ); Mon, 26 Dec 2022 21:36:36 -0500 Received: from mail.nfschina.com (unknown [42.101.60.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B2CCC0; Mon, 26 Dec 2022 18:36:30 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 8660C1A009CD; Tue, 27 Dec 2022 10:36:35 +0800 (CST) X-Virus-Scanned: amavisd-new at nfschina.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 OfFLHNWMXRyK; Tue, 27 Dec 2022 10:36:34 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: chuanjian@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 8F0B51A00934; Tue, 27 Dec 2022 10:36:34 +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 : add detection of null pointers Date: Tue, 27 Dec 2022 10:36:25 +0800 Message-Id: <20221227023625.7261-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 When the pointer variable is judged to be null, null is returned directly. Signed-off-by: Dong Chuanjian --- v2: Directly return when pointer allocation fails. v3: problems in synchronous repair format_ref_list_p diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c index 72bd64f65198..f6684c1d7319 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 == NULL) + return NULL; n += snprintf(*out_str + n, tmp_str_size - n, "|"); @@ -343,6 +345,8 @@ 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); + if (*out_str == NULL) + return NULL; n += snprintf(*out_str + n, tmp_str_size - n, "|"); -- 2.18.2