From: Kevin Wolf Date: Fri, 16 Feb 2018 18:14:55 +0000 (+0100) Subject: rbd: Fix use after free in qemu_rbd_set_keypairs() error path X-Git-Tag: v2.11.2~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f81878152ac50743e94365a68e4204db71362b2;p=thirdparty%2Fqemu.git rbd: Fix use after free in qemu_rbd_set_keypairs() error path If we want to include the invalid option name in the error message, we can't free the string earlier than that. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Eric Blake (cherry picked from commit 71c87815f9e0386b6f3e22942adc956fd603c82f) Signed-off-by: Michael Roth --- diff --git a/block/rbd.c b/block/rbd.c index a76a5e8755b..2de434dfdde 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -265,13 +265,14 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json, key = qstring_get_str(name); ret = rados_conf_set(cluster, key, qstring_get_str(value)); - QDECREF(name); QDECREF(value); if (ret < 0) { error_setg_errno(errp, -ret, "invalid conf option %s", key); + QDECREF(name); ret = -EINVAL; break; } + QDECREF(name); } QDECREF(keypairs);