Skip to contentSkip to conversation

qxl: handling failed allocation

PATCH New Insu Yun 1 participant 1 message Feb 4, 2016

Subsystems (3)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 qxl: handling failed allocation

Since kmalloc can be failed in memory pressure,
check and return error code
otherwise NULL deference could be happened

---
 drivers/gpu/drm/qxl/qxl_kms.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/qxl/qxl_kms.c +3 -0
index b2977a1..02d26b3 100644
@@ -221,6 +221,9 @@ static int qxl_device_init(struct qxl_device *qdev,
 		kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
 			GFP_KERNEL);
 
+	if (!qdev->mem_slots)
+		return -ENOMEM;
+
 	idr_init(&qdev->release_idr);
 	spin_lock_init(&qdev->release_idr_lock);
 	spin_lock_init(&qdev->release_lock);
Signature · 1 line
1.9.1