Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3908662ioa; Tue, 26 Apr 2022 12:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybHA9OikfCDZj7UJueBqY+gi53pcl15s0LDcTYM15va8d6sRbaS1Ia1YUgv/iwBxYWddMM X-Received: by 2002:a63:3f4e:0:b0:3aa:193b:8c5d with SMTP id m75-20020a633f4e000000b003aa193b8c5dmr21189356pga.624.1651000081422; Tue, 26 Apr 2022 12:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651000081; cv=none; d=google.com; s=arc-20160816; b=a6tIm5qZXLkxL7JKdNRx1vwhW56inO/4E72CLp9AF5pasx6h4/eU/Ty35MwUZt8Dda 860AQrAJvQUeTcKDgbKB9e0QjWq1J2C7tDFGoqzeP1sIXN6Kf1Fxis1HRZWl8wUM9k2R fkMpx5UWy4FL+v6eKsXvVnousDpwZ3kDGH5/EehCL6v9WzaeQwiRznj77WDuUhm157/l uyS+oiiY6gxY7eVzuomfDvzsgtXFu4DwtIBXS/LOdj+ILRi5GM+Acac8bf43Gitbk1NS pvnqhTsq2zSM9tKkiBpuWD9aszQBUmQrL4rKwIp6QF0MS6Rp1MfZbz9VM7NeuQieFsyC XGAA== 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=vjdfn16Gs10NKi/3aYwPQxZGNqfdHfO5MYNHQGqYxnw=; b=f1qeZLndERfWFzDyOn4pttRVqZcjNt0DtkY6Yz9+iQ8RCukE+ZVyLnvQEclbm5yWsE HQ14mL1DEyyATnaEJdohqr7g0CRu7XfjoTMEC9p/z1AtkVSH4hM8DRsrYKFcUIn0K0u5 6XMoImiT7qVpj+xIpI7k8ZO3aU4OpBHB5yRYuIHG4gzKujyZP5zjNMjI7PdNYg/1BkqR DssdCqiXYZi54vZzmcGtf37JC+XK2U+TxjdExnmkPmPJiXVxHQu2rKKnCHasve9z10/s So+mocgV8l5xlUIc5B6PkycLWLum/q83Pn6Yg3Sx9ITiysxWceLjM2ADdtQdUgk3njfB klKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DLtPytgU; 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 cm18-20020a056a00339200b0050a5b062419si21010283pfb.54.2022.04.26.12.07.44; Tue, 26 Apr 2022 12:08:01 -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=DLtPytgU; 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 S1347291AbiDZJK1 (ORCPT + 99 others); Tue, 26 Apr 2022 05:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346718AbiDZIuR (ORCPT ); Tue, 26 Apr 2022 04:50:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 623CE16FE23; Tue, 26 Apr 2022 01:38:46 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 67F4860A67; Tue, 26 Apr 2022 08:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71562C385A0; Tue, 26 Apr 2022 08:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962324; bh=T1EzDUfwjggOELHvvCTAYsHts3WIZamAMmLGdfdkNLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLtPytgUrjsAdV1fvqDNqoOHDj/386YsDhJunlF+dgsf6XeHP7cSUUuHmyHRW2DOk W0E7/tqgt8au41YwZvxS5M3HdVEOIoqUKU8Cj8ZQ/nBEQb6XNM7wMrnarr3EqRaQE2 Arf5cftSqui/FvC9UsN7MGf3xFApOwNBv2I7Xh5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoke Wang , Abhinav Kumar , Rob Clark , Sasha Levin Subject: [PATCH 5.15 058/124] drm/msm/disp: check the return value of kzalloc() Date: Tue, 26 Apr 2022 10:20:59 +0200 Message-Id: <20220426081748.950560919@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@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.7 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 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: Xiaoke Wang [ Upstream commit f75e582b0c3ee8f0bddc2248cc8b9175f29c5937 ] kzalloc() is a memory allocation function which can return NULL when some internal memory errors happen. So it is better to check it to prevent potential wrong memory access. Signed-off-by: Xiaoke Wang Reviewed-by: Abhinav Kumar Link: https://lore.kernel.org/r/tencent_B3E19486FF39415098B572B7397C2936C309@qq.com Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c index cabe15190ec1..369e57f73a47 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -169,6 +169,8 @@ void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len, va_list va; new_blk = kzalloc(sizeof(struct msm_disp_state_block), GFP_KERNEL); + if (!new_blk) + return; va_start(va, fmt); -- 2.35.1