* [PATCH v1] drm: omapdrm: Check for NULL return of kzalloc()
@ 2022-03-24 9:12 ` QintaoShen
0 siblings, 0 replies; 2+ messages in thread
From: QintaoShen @ 2022-03-24 9:12 UTC (permalink / raw)
To: tomba; +Cc: dri-devel, linux-kernel, QintaoShen
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v1] drm: omapdrm: Check for NULL return of kzalloc()
@ 2022-03-24 9:12 ` QintaoShen
0 siblings, 0 replies; 2+ messages in thread
From: QintaoShen @ 2022-03-24 9:12 UTC (permalink / raw)
To: tomba; +Cc: QintaoShen, linux-kernel, dri-devel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-25 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 9:12 [PATCH v1] drm: omapdrm: Check for NULL return of kzalloc() QintaoShen
2022-03-24 9:12 ` QintaoShen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.