bdev/lvol: asserting lvol ptr before dereference

Klocwork filtered it out that there is a dereference
of pointer 'lvol' before its NULL check.

Change-Id: I83a026e8762d1e004cf1a351585f48fb1e24ae41
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9208
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Liu Xiaodong 2021-08-18 10:35:47 -04:00 committed by Tomasz Zawadzki
parent 3220a05311
commit 7dcc2507f6

View File

@ -588,9 +588,10 @@ static int
vbdev_lvol_unregister(void *ctx)
{
struct spdk_lvol *lvol = ctx;
struct lvol_bdev *lvol_bdev = SPDK_CONTAINEROF(lvol->bdev, struct lvol_bdev, bdev);
struct lvol_bdev *lvol_bdev;
assert(lvol != NULL);
lvol_bdev = SPDK_CONTAINEROF(lvol->bdev, struct lvol_bdev, bdev);
spdk_bdev_alias_del_all(lvol->bdev);
spdk_lvol_close(lvol, _vbdev_lvol_unregister_cb, lvol_bdev);