Skip to contentSkip to conversation

fix a leak in bch_cached_dev_run()

PATCH Applied Al Viro 2 participants 2 messages Oct 30, 2014 – Nov 1, 2014 bcache (block layer cache)

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 fix a leak in bch_cached_dev_run()

drivers/md/bcache/super.c +4 -1
@@ -878,8 +878,11 @@ void bch_cached_dev_run(struct cached_dev *dc)
 	buf[SB_LABEL_SIZE] = '\0';
 	env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf);
 
-	if (atomic_xchg(&dc->running, 1))
+	if (atomic_xchg(&dc->running, 1)) {
+		kfree(env[1]);
+		kfree(env[2]);
 		return;
+	}
 
 	if (!d->c &&
 	    BDEV_STATE(&dc->sb) != BDEV_STATE_NONE) {
#1 lore raw
Quoted 8 lines · Al Viro
drivers/md/bcache/super.c +0 -0
@@ -878,8 +878,11 @@ void bch_cached_dev_run(struct cached_dev *dc)
 	buf[SB_LABEL_SIZE] = '\0';
 	env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf);

drivers/md/bcache/super.c void bch_cached_dev_run(struct cached_dev *dc) · line 888

Quoted 10 lines
drivers/md/bcache/super.c +4 -1
 
-	if (atomic_xchg(&dc->running, 1))
+	if (atomic_xchg(&dc->running, 1)) {
+		kfree(env[1]);
+		kfree(env[2]);
 		return;
+	}
 
 	if (!d->c &&
 	    BDEV_STATE(&dc->sb) != BDEV_STATE_NONE) {

Thanks, applied