Received: from eggs.gnu.org ([2001:4830:134:3::10]:52982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDDYY-0003Vb-KS for qemu-devel@nongnu.org; Mon, 30 Apr 2018 14:29:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDDYV-0004P8-Bp for qemu-devel@nongnu.org; Mon, 30 Apr 2018 14:29:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56638 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fDDYV-0004OL-6a for qemu-devel@nongnu.org; Mon, 30 Apr 2018 14:29:43 -0400 References: <20180313211441.5179-1-jsnow@redhat.com> <20180313211441.5179-12-jsnow@redhat.com> From: John Snow Message-ID: Date: Mon, 30 Apr 2018 14:29:34 -0400 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 11/13] migration: add postcopy migration of dirty bitmaps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , Vladimir Sementsov-Ogievskiy On 04/27/2018 09:22 AM, Peter Maydell wrote: > On 13 March 2018 at 21:14, John Snow wrote: >> From: Vladimir Sementsov-Ogievskiy >> >> Postcopy migration of dirty bitmaps. Only named dirty bitmaps are migrated. >> >> If destination qemu is already containing a dirty bitmap with the same name >> as a migrated bitmap (for the same node), then, if their granularities are >> the same the migration will be done, otherwise the error will be generated. >> >> If destination qemu doesn't contain such bitmap it will be created. >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy >> Reviewed-by: Dr. David Alan Gilbert >> Message-id: 20180313180320.339796-12-vsementsov@virtuozzo.com >> [Changed '+' to '*' as per list discussion. --js] >> Signed-off-by: John Snow > >> +static int init_dirty_bitmap_migration(void) >> +{ > > Hi; Coverity (CID1390625) complains about a possible dereference > after NULL check in this function: > >> + BlockDriverState *bs; >> + BdrvDirtyBitmap *bitmap; >> + DirtyBitmapMigBitmapState *dbms; >> + BdrvNextIterator it; >> + >> + dirty_bitmap_mig_state.bulk_completed = false; >> + dirty_bitmap_mig_state.prev_bs = NULL; >> + dirty_bitmap_mig_state.prev_bitmap = NULL; >> + dirty_bitmap_mig_state.no_bitmaps = false; >> + >> + for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { >> + const char *drive_name = bdrv_get_device_or_node_name(bs); >> + >> + /* skip automatically inserted nodes */ >> + while (bs && bs->drv && bs->implicit) { >> + bs = backing_bs(bs); >> + } > > The 'bs' test in this while() loop implies that we might > leave the loop because bs == NULL... > >> + >> + for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap; > > ...but this call to bdrv_dirty_bitmap_next() will always > dereference bs, so if it's NULL we'll crash. > >> + bitmap = bdrv_dirty_bitmap_next(bs, bitmap)) > > thanks > -- PMM > I have some patches on the way to clean up this file. Sorry for the delay.