diff mbox

qxl: correctly handling failed allocation

Message ID 1451416674-10618-1-git-send-email-wuninsu@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Insu Yun Dec. 29, 2015, 7:17 p.m. UTC
Since kmalloc can be failed in memory pressure, 
when fails, return error code.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/gpu/drm/qxl/qxl_kms.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

kernel test robot July 9, 2016, 1:41 p.m. UTC | #1
Hi,

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.7-rc6 next-20160708]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Insu-Yun/qxl-correctly-handling-failed-allocation/20151230-031647
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/qxl/qxl_kms.c: In function 'qxl_device_init':
>> drivers/gpu/drm/qxl/qxl_kms.c:224:11: error: 'struct qxl_device' has no member named 'memslots'; did you mean 'mem_slots'?
     if (!qdev->memslots)
              ^~

vim +224 drivers/gpu/drm/qxl/qxl_kms.c

   218			(~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
   219	
   220		qdev->mem_slots =
   221			kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
   222				GFP_KERNEL);
   223	
 > 224		if (!qdev->memslots)
   225			return -ENOMEM;
   226	
   227		idr_init(&qdev->release_idr);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index b2977a1..2e99854 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -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->memslots)
+		return -ENOMEM;
+
 	idr_init(&qdev->release_idr);
 	spin_lock_init(&qdev->release_idr_lock);
 	spin_lock_init(&qdev->release_lock);