Skip to content

Commit bdc361a

Browse files
committed
rbd: fix memory leak when fails to get the address
Signed-off-by: Xiubo Li <[email protected]>
1 parent 9fa64b3 commit bdc361a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

rbd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,10 +1210,12 @@ static int tcmu_rbd_open(struct tcmu_device *dev, bool reopen)
12101210
#ifdef LIBRADOS_SUPPORTS_GETADDRS
12111211
/* Get current entry address for the image */
12121212
ret = rados_getaddrs(state->cluster, &state->addrs);
1213-
tcmu_dev_info(dev, "address: {%s}\n", state->addrs);
1213+
if (ret < 0) {
1214+
tcmu_dev_err(dev, "failed getting the address\n");
1215+
goto stop_image;
1216+
}
1217+
tcmu_dev_info(dev, "opened, the address: {%s}\n", state->addrs);
12141218
pthread_mutex_unlock(&rdev->priv_lock);
1215-
if (ret < 0)
1216-
return ret;
12171219
#endif
12181220

12191221
free(dev_cfg_dup);

0 commit comments

Comments
 (0)