Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1145272pxb; Thu, 24 Mar 2022 13:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIhS2gg2WhNyT+UhCZ/VQvM4x81ZUGSjIqVjCgdIdvZ6mqvsEWyB4NRNyiwAY5gTypWHZU X-Received: by 2002:a65:6d8b:0:b0:376:bfb9:1f3b with SMTP id bc11-20020a656d8b000000b00376bfb91f3bmr5295512pgb.427.1648154558705; Thu, 24 Mar 2022 13:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648154558; cv=none; d=google.com; s=arc-20160816; b=o7VqJ00/8AHubmLRW7xkQwXfkPDrHEvspAZ6GF+eYEVaxNXwRdh1qL0CWsDfHEiW0C a9G0LN0hI+33pVp8bqO44b9hHb2SEFijuy3JbHJlPfxLntynMYrZnBdua0fBUWf6lFyh bzpvndd+C371rYaZMjoIPRtcOxxqSir+QhsntaaqwzJ38mWGcmATERpnfjxC0tkiiDla nuF9KJQbYtI6tqobEjTamDMF6eqdU4u/rdsPFKb8LALbBVHUvEncr/oehys5JT3+aBJO RR7wwKoRfApAetJt6FcjtWl7pKP0OoouHuzjI0Yciar+8BHz63B/0Yyi6acGNM00QwtI HPqA== 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=Y63xt4boxyExZq6hhVN4HB4jAAAEHQlGefrZDnFYgGg=; b=rD+bvJHRLVr+ZcvajIgZ5UJciLhPKwMNn/Fv1Zip8BRue2Pzi5LmDWwLVwPNuNB+Rf Nb4fGUgGfuI7ggQiLylzA/Ql3vv4O0dpyorAGtYPGU2HHFzBZTIuKQCxv+OVzVIJ1Q7O i5z48xvWGoXtlg3/F0jwEeL1TChNHCdEzNTpzwn+fqdbdNXUoLXsnEoPxoYyLi8WyXWU 5RWBdr4ylTn2qGSY5dGvv+uMYUrX6RinEIN3Mm6ytQnJV+RLzkd85p9GKqIlHUL2nGTD UF/iR70AfXEDzw+TCpYwcYVrtn7wZqy9er+uDtsPakDNhxz/oDMbErL/dfwEvsSTi7Nm lypg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=A9epg5pG; 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=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a654d46000000b003816043efd9si397250pgt.462.2022.03.24.13.42.16; Thu, 24 Mar 2022 13:42:38 -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=@163.com header.s=s110527 header.b=A9epg5pG; 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=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348899AbiCXJN6 (ORCPT + 99 others); Thu, 24 Mar 2022 05:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238181AbiCXJN5 (ORCPT ); Thu, 24 Mar 2022 05:13:57 -0400 Received: from m12-11.163.com (m12-11.163.com [220.181.12.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 865E09D0ED for ; Thu, 24 Mar 2022 02:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Y63xt4boxyExZq6hhV N4HB4jAAAEHQlGefrZDnFYgGg=; b=A9epg5pGbMDc3HSK9XABSIllTpHrUkBJsS FXVkVLZ4uTM2wB+GzQtLn4uVvXdZrSd3Cwnog29OycmaHCY0HWDgKppeD39hlHmX SNGqilINnEfPkkQwb+7jYjfL2Dnv2utnOwVTe51kEOZwzbPUQLVvAcuCiTnY4IkV mMJfpcDEU= Received: from localhost (unknown [159.226.95.33]) by smtp7 (Coremail) with SMTP id C8CowADXcrjqNTxieYAGEA--.7423S2; Thu, 24 Mar 2022 17:12:10 +0800 (CST) From: QintaoShen To: tomba@kernel.org Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, QintaoShen Subject: [PATCH v1] drm: omapdrm: Check for NULL return of kzalloc() Date: Thu, 24 Mar 2022 17:12:07 +0800 Message-Id: <1648113127-8020-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C8CowADXcrjqNTxieYAGEA--.7423S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kry3JFy5urWxtw47Zw43KFg_yoW8GFy8pF WDta4jkr18AF42grnrA3WqyFy5Ga13CF1Sgr9ruwna9w4rArW7Xwn8JFy3Arykuws3Ar42 gF4kt3WfGrn8Cr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JUO18gUUUUU= X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/xtbCbgrNH2BbCZwkzwAAsz X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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 kzalloc() is a memory allocation function which may return NULL. It is better to check the return value of it to catch the error in time. Signed-off-by: QintaoShen --- drivers/gpu/drm/omapdrm/omap_crtc.c | 3 +++ drivers/gpu/drm/omapdrm/omap_irq.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 06a719c..fcd76ea 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -166,6 +166,9 @@ void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) dispc_mgr_enable(priv->dispc, channel, enable); omap_crtc->enabled = enable; + if (!wait) + return ; + ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100)); if (ret) { dev_err(dev->dev, "%s: timeout waiting for %s\n", diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c index 4aca14d..a234462 100644 --- a/drivers/gpu/drm/omapdrm/omap_irq.c +++ b/drivers/gpu/drm/omapdrm/omap_irq.c @@ -45,6 +45,9 @@ struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev, struct omap_irq_wait *wait = kzalloc(sizeof(*wait), GFP_KERNEL); unsigned long flags; + if (!wait) + return NULL; + init_waitqueue_head(&wait->wq); wait->irqmask = irqmask; wait->count = count; -- 2.7.4