mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
block: allow bdrv_unref() to be passed NULL pointers
If bdrv_unref() is passed a NULL BDS pointer, it is safe to exit with no operation. This will allow cleanup code to blindly call bdrv_unref() on a BDS that has been initialized to NULL. Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
58803ce74f
commit
9a4d5ca607
1 changed files with 3 additions and 0 deletions
3
block.c
3
block.c
|
@ -5381,6 +5381,9 @@ void bdrv_ref(BlockDriverState *bs)
|
|||
* deleted. */
|
||||
void bdrv_unref(BlockDriverState *bs)
|
||||
{
|
||||
if (!bs) {
|
||||
return;
|
||||
}
|
||||
assert(bs->refcnt > 0);
|
||||
if (--bs->refcnt == 0) {
|
||||
bdrv_delete(bs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue