Skip to contentSkip to conversation

drm: omapdrm: Check for NULL return of kzalloc()

PATCH New QintaoShen 1 participant 1 message Mar 24, 2022

Subsystems (3)
lore
Share & tools
lore

QintaoShen

author
#0 lore raw

PATCH 1/1 drm: omapdrm: Check for NULL return of kzalloc()

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.

---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 3 +++
 drivers/gpu/drm/omapdrm/omap_irq.c  | 3 +++
 2 files changed, 6 insertions(+)
drivers/gpu/drm/omapdrm/omap_crtc.c +3 -0
index 06a719c..fcd76ea 100644
@@ -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",
drivers/gpu/drm/omapdrm/omap_irq.c +3 -0
index 4aca14d..a234462 100644
@@ -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;
Signature · 1 line
2.7.4