lib/ftl: verify that iov is not NULL during read header completion
Moved the spdk_bdev_io_get_iovec() after the verification that io succeeded. Then added return path when iov could not be retrived from bdevio. Change-Id: I2638e6657fd08a2dd85ab0906383cecef8fb4f4a Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462507 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
07f432641a
commit
94bf29d268
@ -883,16 +883,21 @@ ftl_nv_cache_read_header_cb(struct spdk_bdev_io *bdev_io, bool success, void *cb
|
||||
int iov_cnt = 0, i, rc;
|
||||
uint32_t checksum;
|
||||
|
||||
bdev = spdk_bdev_desc_get_bdev(nv_cache->bdev_desc);
|
||||
spdk_bdev_io_get_iovec(bdev_io, &iov, &iov_cnt);
|
||||
hdr = iov[0].iov_base;
|
||||
|
||||
if (!success) {
|
||||
SPDK_ERRLOG("Unable to read non-volatile cache metadata header\n");
|
||||
ftl_restore_complete(restore, -ENOTRECOVERABLE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
bdev = spdk_bdev_desc_get_bdev(nv_cache->bdev_desc);
|
||||
spdk_bdev_io_get_iovec(bdev_io, &iov, &iov_cnt);
|
||||
if (!iov) {
|
||||
SPDK_ERRLOG("Unable to get the iov for non-volatile cache metadata header\n");
|
||||
ftl_restore_complete(restore, -ENOTRECOVERABLE);
|
||||
goto out;
|
||||
}
|
||||
hdr = iov[0].iov_base;
|
||||
|
||||
checksum = spdk_crc32c_update(hdr, offsetof(struct ftl_nv_cache_header, checksum), 0);
|
||||
if (checksum != hdr->checksum) {
|
||||
SPDK_ERRLOG("Invalid header checksum (found: %"PRIu32", expected: %"PRIu32")\n",
|
||||
|
Loading…
Reference in New Issue
Block a user