[Drbd-dev] [PATCH] drbd: Check-kmalloc-return-value before use it

Steven Liu lingjiujianke at gmail.com
Tue May 18 07:30:16 CEST 2010


Check-kmalloc-return-value before use it

Signed-off-by: Liu Qi <lingjiujianke at gmail.com>
---
 drivers/block/drbd/drbd_receiver.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c
b/drivers/block/drbd/drbd_receiver.c
index 3f096e7..533df04 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2977,6 +2977,10 @@ static int receive_uuids(struct drbd_conf
*mdev, struct p_header *h)
        return FALSE;

    p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO);
+   if(p_uuid == NULL){
+       printk(KERN_ERR "Kmalloc p_uuid failed in %s \n", __func__);
+       return FALSE;
+   }

    for (i = UI_CURRENT; i < UI_EXTENDED_SIZE; i++)
        p_uuid[i] = be64_to_cpu(p->uuid[i]);
--
1.7.1


Best regards


More information about the drbd-dev mailing list