From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7LGI-0006sZ-1m for qemu-devel@nongnu.org; Thu, 17 Nov 2016 06:53:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7LGH-0001gl-8b for qemu-devel@nongnu.org; Thu, 17 Nov 2016 06:53:50 -0500 Date: Thu, 17 Nov 2016 06:53:41 -0500 From: Jeff Cody Message-ID: <20161117115341.GB6353@localhost.localdomain> References: <1479378608-11962-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479378608-11962-1-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.8] gluster: Fix use after free in glfs_clear_preopened() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, prasanna.kalever@redhat.com, qemu-devel@nongnu.org On Thu, Nov 17, 2016 at 11:30:08AM +0100, Kevin Wolf wrote: > This fixes a use-after-free bug introduced in commit 6349c154. We need > to use QLIST_FOREACH_SAFE() when freeing elements in the loop. Spotted > by Coverity. > > Signed-off-by: Kevin Wolf > --- > block/gluster.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/block/gluster.c b/block/gluster.c > index 0ce15f7..891c13b 100644 > --- a/block/gluster.c > +++ b/block/gluster.c > @@ -239,12 +239,13 @@ static glfs_t *glfs_find_preopened(const char *volume) > static void glfs_clear_preopened(glfs_t *fs) > { > ListElement *entry = NULL; > + ListElement *next; > > if (fs == NULL) { > return; > } > > - QLIST_FOREACH(entry, &glfs_list, list) { > + QLIST_FOREACH_SAFE(entry, &glfs_list, list, next) { > if (entry->saved.fs == fs) { > if (--entry->saved.ref) { > return; > -- > 1.8.3.1 > Thanks, Applied to my block branch: git://github.com/codyprime/qemu-kvm-jtc.git block -Jeff