dif: Change check of metadata size

Metadata size was checked if it is not zero.
This patch changes the check to if it is not smaller than DIF field.

Change-Id: Ibdc38367091af2d07a8443bf6cda6b4b5a23306d
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/438363
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-12-28 08:04:26 +09:00 committed by Jim Harris
parent a5e3d61d6b
commit c0839cc0c9

View File

@ -320,12 +320,13 @@ spdk_dif_generate(struct iovec *iovs, int iovcnt,
{
uint32_t guard_interval;
if (md_size == 0) {
if (!_are_iovs_valid(iovs, iovcnt, block_size * num_blocks)) {
SPDK_ERRLOG("Size of iovec array is not valid.\n");
return -EINVAL;
}
if (!_are_iovs_valid(iovs, iovcnt, block_size * num_blocks)) {
SPDK_ERRLOG("Size of iovec array is not valid.\n");
if (md_size < sizeof(struct spdk_dif)) {
SPDK_ERRLOG("Metadata size is smaller than DIF size.\n");
return -EINVAL;
}
@ -570,12 +571,13 @@ spdk_dif_verify(struct iovec *iovs, int iovcnt,
{
uint32_t guard_interval;
if (md_size == 0) {
if (!_are_iovs_valid(iovs, iovcnt, block_size * num_blocks)) {
SPDK_ERRLOG("Size of iovec array is not valid.\n");
return -EINVAL;
}
if (!_are_iovs_valid(iovs, iovcnt, block_size * num_blocks)) {
SPDK_ERRLOG("Size of iovec array is not valid.\n");
if (md_size < sizeof(struct spdk_dif)) {
SPDK_ERRLOG("Metadata size is smaller than DIF size\n");
return -EINVAL;
}
@ -680,7 +682,7 @@ spdk_dif_inject_error(struct iovec *iovs, int iovcnt,
uint32_t guard_interval;
int rc;
if (md_size == 0) {
if (md_size < sizeof(struct spdk_dif)) {
return -EINVAL;
}