[Drbd-dev] [PATCH 1/1] drbd: check return of kmalloc in receive_uuids

Jing Wang windsdaemon at gmail.com
Thu Oct 25 09:00:56 CEST 2012


Signed-off-by: Jing Wang <windsdaemon at gmail.com>
---
 drivers/block/drbd/drbd_receiver.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index c74ca2d..4227f38 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3076,10 +3076,14 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
 static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
 {
 	struct p_uuids *p = &mdev->data.rbuf.uuids;
-	u64 *p_uuid;
+	u64 *p_uuid = NULL;
 	int i, updated_uuids = 0;
 
 	p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO);
+	if (!p_uuid) {
+		dev_err(DEV, "kmalloc of p_uuid failed\n");
+		return -ENOMEM;
+	}
 
 	for (i = UI_CURRENT; i < UI_EXTENDED_SIZE; i++)
 		p_uuid[i] = be64_to_cpu(p->uuid[i]);
-- 
1.7.5.4



More information about the drbd-dev mailing list