Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2151385pxb; Fri, 25 Mar 2022 12:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUaYQza+GLEnY8pB8haYBl5P6wOcY6Vdz0DAE6xQi8Q769tmTB1h/6Ak96XijxFZYLybfW X-Received: by 2002:a17:90a:644c:b0:1c6:2577:6577 with SMTP id y12-20020a17090a644c00b001c625776577mr26120881pjm.217.1648234871189; Fri, 25 Mar 2022 12:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648234871; cv=none; d=google.com; s=arc-20160816; b=SZFGfffYwdsZCUImqxbzSQFNB8gEYbb96deur+cogjARtunwPl5kC+g/5AhJr/FGhA yvYHgoAHyrMtfRYjVvWVvJFI5mhqMwRtssyfzgFzJUuRvkcE6QKpADHpx/Om+C/KOYy9 g5BoEac1mh+F6mq0hVgOFU/xpZ7g7HGSxuPEERIZywRIReFSCOcWAP+jzV/y0wNer6ot Ayo42iNnExGuTKHcgFVF65C9IJAWCG/pcncywQoCFUHTsllrHjb4Bwym5CbnkFwtoaF6 93aHgUdx4YCLqrU+b6mWLZg80Qs/AZ9oKAGNLNH9Mmyd/H+S61SgzCOxoeDaSRJlgeTQ hG4Q== 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 :dkim-signature; bh=3xtT2Ivblp3LZK9HllIJx+ml2hb8oqzdRwacDZ+ib0o=; b=OjK4W7cX/G0fZ17qEdZpKJik960B38mr+n1126xCWu5yhXbrthcLHVdwlDVGDvVanr 1C8buUr6L6TVvBqI1W/rAqsQwznFItJRG8Eh0dP1xP19xH/Ky64yt8SDXEbAeWx+qm2f ge1CDHsAvOfTFL6Mp8GDfzX0Gx6p2jC6BfgWaRt+8s//Njr0evvzBrRdGbxWLYkNV106 LoonQy6TRp064QzNqTZQypqmuZ0mnPNEHe8LuLmsnTQxLvF+0bMDvJXeGDs0iO9VkdZN QD0eCas+n/tGZFw1sYEi70p5DkmU7pzVBAfVq8J8V0FvND2pwx6uJjSgdqPGW/B5Rt7p zEIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=XP3P9pbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v9-20020a1709028d8900b00153b4c149a9si1853332plo.624.2022.03.25.12.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:01:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=XP3P9pbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F097E1F9FCF; Fri, 25 Mar 2022 11:13:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349064AbiCXI6A (ORCPT + 99 others); Thu, 24 Mar 2022 04:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349095AbiCXI5x (ORCPT ); Thu, 24 Mar 2022 04:57:53 -0400 Received: from m12-12.163.com (m12-12.163.com [220.181.12.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6ABE9D072 for ; Thu, 24 Mar 2022 01:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=3xtT2Ivblp3LZK9Hll IJx+ml2hb8oqzdRwacDZ+ib0o=; b=XP3P9pbd1UjG7TvVYAsllbWpF45yqHYmGp IlAmdNIO2XDVcTp/KBl3W+yQ8wcHN/Q6TzJ1+ffxfsuS2fJL2Q7xPKYDibcQMwRv J6IKuez/e704yfD0JKcMQKEPhJbeoXV62fXjYVmssFtWykh7/zk5ifbOYHQgHfbx g3IT/XAmA= Received: from localhost (unknown [159.226.95.33]) by smtp8 (Coremail) with SMTP id DMCowADnu4wXMjxi8Rv_Bg--.18696S2; Thu, 24 Mar 2022 16:55:51 +0800 (CST) From: QintaoShen To: sean@poorly.run Cc: quic_abhinavk@quicinc.com, robdclark@gmail.com, linux-kernel@vger.kernel.org, QintaoShen Subject: [PATCH v1] drm/msm: Check for NULL return of kzalloc() Date: Thu, 24 Mar 2022 16:55:50 +0800 Message-Id: <1648112150-6515-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DMCowADnu4wXMjxi8Rv_Bg--.18696S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7JFyUtw4xJFW8Cr1UAFy5Jwb_yoWfXFb_C3 WxZFn3Jry2kFn8K3W7Cr4xZryIyw1F9Fy8Xwn3t3yay3s7Z3W7Xa42yrWrXr1j9Fy7WFyj kan7Za45CrsrWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7VUUdWrPUUUUU== X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/xtbBdRfNH1aEB0PumAAAsQ X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 The allocation of kzalloc() may return NULL, which would bring a NULL pointer dereference bug. To avoid this confusion, it is better to check the return value of kzalloc(). Signed-off-by: QintaoShen --- 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 5d2ff67..d017deb 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -176,6 +176,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.7.4