From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hQ-00010S-SQ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hM-00082y-0b for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:48 -0400 Sender: fluxion From: Michael Roth Date: Mon, 18 Jun 2018 20:41:45 -0500 Message-Id: <20180619014319.28272-20-mdroth@linux.vnet.ibm.com> In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 019/113] rbd: Fix use after free in qemu_rbd_set_keypairs() error path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Kevin Wolf From: Kevin Wolf 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 --- block/rbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/rbd.c b/block/rbd.c index a76a5e8755..2de434dfdd 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); -- 2.11.0