Skip to contentSkip to conversation

drbd: fix memory leak

PATCH In review Dan Carpenter 3 participants 5 messages Apr 22, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drbd: fix memory leak

We leak memory if "--dry-run" is not supported by the peer.

drivers/block/drbd/drbd_main.c +1 -0
index 67e0fc5..93d1f9b 100644
@@ -1695,6 +1695,7 @@ int drbd_send_protocol(struct drbd_conf *mdev)
 			cf |= CF_DRY_RUN;
 		else {
 			dev_err(DEV, "--dry-run is not supported by peer");
+			kfree(p);
 			return 0;
 		}
 	}
#1 lore raw
Quoted 9 lines · Dan Carpenter

We leak memory if "--dry-run" is not supported by the peer.

drivers/block/drbd/drbd_main.c +0 -0
index 67e0fc5..93d1f9b 100644

drivers/block/drbd/drbd_main.c int drbd_send_protocol(struct drbd_conf *mdev) · line 1701

Quoted 7 lines
drivers/block/drbd/drbd_main.c +1 -0
@@ -1695,6 +1695,7 @@ int drbd_send_protocol(struct drbd_conf *mdev)
 			cf |= CF_DRY_RUN;
 		else {
 			dev_err(DEV, "--dry-run is not supported by peer");
+			kfree(p);
 			return 0;
 		}
 	}

Yep, that's a leak. I have applied it for 2.6.34.

Signature · 1 line
Jens Axboe
maintainer
#2 lore raw

Hi Jens,

Please apply the following patch as well.

PS: I have put both at git://git.drbd.org/linux-2.6-drbd.git for-jens

Best,
Phil

maintainer
#3 lore raw

PATCH 1/1 drbd: Terminate a connection early if sending the protocol fails

---
 drivers/block/drbd/drbd_receiver.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/block/drbd/drbd_receiver.c +2 -1
index ed9f1de..3f096e7 100644
@@ -899,7 +899,8 @@ retry:
 
 	drbd_thread_start(&mdev->asender);
 
-	drbd_send_protocol(mdev);
+	if (!drbd_send_protocol(mdev))
+		return -1;
 	drbd_send_sync_param(mdev, &mdev->sync_conf);
 	drbd_send_sizes(mdev, 0);
 	drbd_send_uuids(mdev);
Signature · 1 line
1.6.3.3
#4 lore raw
In reply to Philipp Reisner
Quoted 5 lines · Philipp Reisner

Hi Jens,

Please apply the following patch as well.

PS: I have put both at git://git.drbd.org/linux-2.6-drbd.git for-jens

Thanks, I just hand applied the 2nd one since the first one was already there.

Signature · 1 line
Jens Axboe