[LU-5430] Function lmv_mds_md_size() can return -EINVAL which is never checked Created: 30/Jul/14  Updated: 31/Jan/22

Status: Open
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.15.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Dmitry Eremin (Inactive) Assignee: WC Triage
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Related
is related to LU-5439 Function lustre_msg_buflen() can retu... Resolved
Severity: 3
Rank (Obsolete): 15120

 Description   
static inline int lmv_mds_md_size(int stripe_count, unsigned int lmm_magic)
{
	switch (lmm_magic) {
	case LMV_MAGIC_V1:{
		struct lmv_mds_md_v1 *lmm1;

		return sizeof(*lmm1) + stripe_count *
				       sizeof(lmm1->lmv_stripe_fids[0]);
	}
	default:
		return -EINVAL;
	}
}

It's not critical now because of magic is LMV_MAGIC_V1 always but can affect in the future.

In few places the value checked for zero.

lmm_size = lmv_mds_md_size(stripe_count, le32_to_cpu((*lmmp)->lmv_magic));
if (lmm_size == 0)
	RETURN(-EINVAL);

So, probably it will be better return zero in case of wrong magic and return type change to size_t.


Generated at Sat Feb 10 01:51:25 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.