It could be that we error out while the RBD image has not been
opened yet. This would cause us to call rbd_close() on pointer
which has not been initialized.
Set it to NULL by default and only close if it is not NULL.
Signed-off-by: Wido den Hollander <wido@widodh.nl>
{
int ret = -1;
int r = 0;
- rbd_image_t image;
+ rbd_image_t image = NULL;
r = rbd_open(ptr->ioctx, vol->name, &image, NULL);
if (r < 0) {
virReportSystemError(-r, _("failed to open the RBD image '%s'"),
vol->name);
- return ret;
+ goto cleanup;
}
rbd_image_info_t info;
ret = 0;
cleanup:
- rbd_close(image);
+ if (image)
+ rbd_close(image);
return ret;
}