From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoSMv-0004Jd-6X for qemu-devel@nongnu.org; Tue, 20 Oct 2015 04:34:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoSMr-0005tc-Db for qemu-devel@nongnu.org; Tue, 20 Oct 2015 04:34:05 -0400 Date: Tue, 20 Oct 2015 10:33:51 +0200 From: Kevin Wolf Message-ID: <20151020083351.GA6519@noname.redhat.com> References: <1445270025-22999-1-git-send-email-mreitz@redhat.com> <1445270025-22999-28-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445270025-22999-28-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 27/39] block: Add blk_remove_bs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Am 19.10.2015 um 17:53 hat Max Reitz geschrieben: > This function removes the BlockDriverState associated with the given > BlockBackend from that BB and sets the BDS pointer in the BB to NULL. > > Signed-off-by: Max Reitz > --- > block/block-backend.c | 12 ++++++++++++ > include/sysemu/block-backend.h | 1 + > 2 files changed, 13 insertions(+) > > diff --git a/block/block-backend.c b/block/block-backend.c > index 19fdaae..eb7409c 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -334,6 +334,18 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) > } > > /* > + * Disassociates the currently associated BlockDriverState from @blk. > + */ > +void blk_remove_bs(BlockBackend *blk) > +{ > + blk_update_root_state(blk); > + > + bdrv_unref(blk->bs); > + blk->bs->blk = NULL; Use after free? > + blk->bs = NULL; > +} Kevin