From: QintaoShen <unSimple1993@163.com>
To: tomba@kernel.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
QintaoShen <unSimple1993@163.com>
Subject: [PATCH v1] drm: omapdrm: Check for NULL return of kzalloc()
Date: Thu, 24 Mar 2022 17:12:07 +0800 [thread overview]
Message-ID: <1648113127-8020-1-git-send-email-unSimple1993@163.com> (raw)
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 <unSimple1993@163.com>
---
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
reply other threads:[~2022-03-24 9:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1648113127-8020-1-git-send-email-unSimple1993@163.com \
--to=unsimple1993@163.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tomba@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®