Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp953382pxb; Wed, 6 Apr 2022 05:12:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRJ1x730FtRutyK3xoILWN+yXwzGE/C6BSOVBoZ2BcNWcZ+uUUtD4bIFfZ0iurjwYhlAG3 X-Received: by 2002:a17:902:ab57:b0:156:c63e:9d1a with SMTP id ij23-20020a170902ab5700b00156c63e9d1amr8396115plb.49.1649247151522; Wed, 06 Apr 2022 05:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247151; cv=none; d=google.com; s=arc-20160816; b=wziHq3OKyFY4zHXTGqZGoFoKrQfkX66JrQPI5axpmBt9x3Y9vU8XVCFLhvp1WxFOXl m7wlpjzn+o6T6gDEHtMZx4TEr/BwvQKTL50Y/rmJHAqJ21jcnd1iK4JoOnmrCBWz+qqr tUORaFv77OOCoGPbtyhr9Yf3GTBqbikR2RkzOPUuASEyQWHbA+QAHMbmU926vHkYuhNn SgERiN1YvXuVuP78brbDjWdio4qvRGPb3SV5dgG5BM2WGGY4M+PXnUBDznhd7O4kyrWR Sl0k1t2n/N6W8m0bHVWQ/fRMuqmMO8wGO+CLexsLYvXohtoDxR2EY1gLln/99T0TYIC2 lHNA== 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=KQKi0DWtvLLGu0zmhlzQmC7H7zI7SYTeaEeJEl+COmpFydLKnyBQ7X3IbvI6jNHbNZ T1iJ64bfy2sKcwy6mMuoDJNu3H0dab8Txx7b94nwA6q1QSRwHR6xp+zgPFH3cUDG6EpL JiErXgF0BHncztx2ls6hjrzwr2QbCCDEdCNT3FSCcLdaPMBqzgj8Zdet14vTS9DzbXFI PpqvP8DVTxiv1GuYqMSrLKw3aZOuOLW8nVx6qyRSPBmgqaeujXF64K+jX9pOUf1LA2dt Rcowync80k5CAYM3kqboFvcIB3fjtrpaSFFuF/rUliUnobFqE4JffTYCFtYgSQS8j6jr 1Ygw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=snxLf7VA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bg13-20020a17090b0d8d00b001bf691f3264si4579770pjb.19.2022.04.06.05.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:12:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=snxLf7VA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED40D6A910C; Wed, 6 Apr 2022 03:50:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346999AbiDEPXl (ORCPT + 99 others); Tue, 5 Apr 2022 11:23:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347167AbiDEJqE (ORCPT ); Tue, 5 Apr 2022 05:46:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3B0DD943; Tue, 5 Apr 2022 02:32:33 -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 4235BB81CC6; Tue, 5 Apr 2022 09:32:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA4A0C385A6; Tue, 5 Apr 2022 09:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151151; bh=ej8YD3xB5V9woQICwarpd25mwtsSDI1jBorcXHF2D0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snxLf7VAcq0TIv+cGX4I+1B2cQb1ue2jRfbZB2BJ3d/eksZGtaryOoAeIvUmcICpp bfCyvA64fGARhOj7B7Qgo4mIc1YMfTBBYcT3GN1pVVWJHhm2WdBI2Csb0pvaso+5ZJ 9MY9bnI/VwOYSaVzvRt6MYpxhoJ/0JB4nQxzDrt4= 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.15 312/913] media: ti-vpe: cal: Fix a NULL pointer dereference in cal_ctx_v4l2_init_formats() Date: Tue, 5 Apr 2022 09:22:54 +0200 Message-Id: <20220405070349.206230566@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 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