Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp690454pxb; Tue, 5 Apr 2022 18:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1ezIpX+jq2MfHrKyfXXaAa6X7JP+R/8l0Iq/YjenG90Jb2MLtGTVY5tiaa4OODgTmbDiO X-Received: by 2002:a17:903:240c:b0:153:c8df:7207 with SMTP id e12-20020a170903240c00b00153c8df7207mr6233890plo.44.1649210188873; Tue, 05 Apr 2022 18:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210188; cv=none; d=google.com; s=arc-20160816; b=VlMNumR9L0rwv+SAzSav5QI/wGQLTRIwV5z/xt/TGGZ8Q5NBV9xL2715yTeBoYXWbC fewc30PSMdxWmRcVfP1o9QA3q5Kssq2sMkMOh7DW1J/YmqSllNB3u5+qD/aToOtFNkOR O/BSxJYi/bsC8iG4Fe15HM3FeumwcBkWGxKmX3y+6bhYe9486jZGMso8FeUeVlOXI0pv 1FBh7e5+2tdt9HYOgHNihpD4iZVZDrj89EaZz57nCbPctMq2+TldfbQ9O7pBAe4N55nq 3FEB7790ff0jljDqpiQcjkYM4zTLSS+bwSyRSB2kVNoN4EgBAsjy4nWBVzpBYmOe9tXY acXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zQhM6zqD3jHrt2c+v2jbQNw03OKR88jUW6Hhi8d2Uj8=; b=MdMS1tDxfPSqm8cT3vCMOGjkcbmHr+xVsT4cB3Ro6av6E/ynoxIpYBbAuvQUUFHDvl 0jbb7qvfQzFAZukXH/iAzc5LUMAgEd7tD5YjiMqvpg/0OYL3byvToab5LbU+46m0+cX2 pwtggt0lAEx20X+rLdB6mYK9mKpzo6cP7zzrNuUBcq05ci33dvNPAQ0xXp8qVD3te6Bv 1iFSAPbwLkaB0jfcB+/ExH8niNAVmKkJZKHg3btiCWMUE6DSBnLRNPfUqe8hJntJOSAj d7m3zmYCqNcGapJO3wA9pxgB6t+kARgMkUgwpmsImHIwFYRS6vmTaGvZEp+Tk+z1J3i9 EiKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DCL5pr7U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a635750000000b003816043ee18si14715360pgm.13.2022.04.05.18.56.14; Tue, 05 Apr 2022 18:56:28 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DCL5pr7U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349026AbiDELxy (ORCPT + 99 others); Tue, 5 Apr 2022 07:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244916AbiDEIwr (ORCPT ); Tue, 5 Apr 2022 04:52:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBE62495C; Tue, 5 Apr 2022 01:46:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CC637B81C19; Tue, 5 Apr 2022 08:46:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F317C385A1; Tue, 5 Apr 2022 08:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148375; bh=ej8YD3xB5V9woQICwarpd25mwtsSDI1jBorcXHF2D0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DCL5pr7US6Vohpk0TRa27dnzxku1bLcr1LzFeNYQggFWd0dtPTvrIPAIZFUQ54W// G7MqEEb54son5U/3FVlG1hOvJGToeIuh+bRlU71l+63BT2bIenn3M7+R2i5rXekt+G 2Zi/5EOCTbK/17HnOUGyL+I8qj9cnOXwav/SLGNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Pratyush Yadav , Laurent Pinchart , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.16 0333/1017] media: ti-vpe: cal: Fix a NULL pointer dereference in cal_ctx_v4l2_init_formats() Date: Tue, 5 Apr 2022 09:20:46 +0200 Message-Id: <20220405070404.166454645@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Zhou Qingyang [ Upstream commit abd77889851d2ead0d0c9c4d29f1808801477b00 ] In cal_ctx_v4l2_init_formats(), devm_kzalloc() is assigned to ctx->active_fmt and there is a dereference of it after that, which could lead to NULL pointer dereference on failure of devm_kzalloc(). Fix this bug by adding a NULL check of ctx->active_fmt. This bug was found by a static analyzer. Builds with 'make allyesconfig' show no new warnings, and our static analyzer no longer warns about this code. Fixes: 7168155002cf ("media: ti-vpe: cal: Move format handling to cal.c and expose helpers") Signed-off-by: Zhou Qingyang Reviewed-by: Pratyush Yadav Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/ti-vpe/cal-video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c index 7799da1cc261..3e936a2ca36c 100644 --- a/drivers/media/platform/ti-vpe/cal-video.c +++ b/drivers/media/platform/ti-vpe/cal-video.c @@ -823,6 +823,9 @@ static int cal_ctx_v4l2_init_formats(struct cal_ctx *ctx) /* Enumerate sub device formats and enable all matching local formats */ ctx->active_fmt = devm_kcalloc(ctx->cal->dev, cal_num_formats, sizeof(*ctx->active_fmt), GFP_KERNEL); + if (!ctx->active_fmt) + return -ENOMEM; + ctx->num_active_fmt = 0; for (j = 0, i = 0; ; ++j) { -- 2.34.1