Skip to contentSkip to conversation

drbd: check return of kmalloc in receive_uuids

PATCH In review Jing Wang 2 participants 2 messages Oct 27, 2012 – Oct 29, 2012

Subsystems (2)
lore
Share & tools
lore

Jing Wang

author
#0 lore raw

PATCH 1/1 drbd: check return of kmalloc in receive_uuids

---
 drivers/block/drbd/drbd_receiver.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/block/drbd/drbd_receiver.c +5 -1
index c74ca2d..4227f38 100644
@@ -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]);
Signature · 1 line
1.7.5.4
maintainer
#1 lore raw

Hi,

Thanks for pointint this out. I fixed your patch for the drbd-8.3 context and applied it. See:
http://git.drbd.org/gitweb.cgi?p=drbd-8.3.git;a=commit;h=371289b8b632e8b4e364563faa430ff3b6d7d1d9

best,
Phil

Quoted 25 lines
---
 drivers/block/drbd/drbd_receiver.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/block/drbd/drbd_receiver.c index c74ca2d..4227f38 100644

drivers/block/drbd/drbd_receiver.c +0 -0
@@ -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) {

drivers/block/drbd/drbd_receiver.c +5 -1
 	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]);