Skip to content
Snippets Groups Projects
Commit 7c46835e authored by Roopa Prabhu's avatar Roopa Prabhu Committed by David S. Miller
Browse files

enic: Use offsetof macro in vic tlv length calculation

parent ae94abe1
No related merge requests found
...@@ -54,8 +54,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length, ...@@ -54,8 +54,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
if (!vp || !value) if (!vp || !value)
return -EINVAL; return -EINVAL;
if (ntohl(vp->length) + sizeof(*tlv) + length > if (ntohl(vp->length) + offsetof(struct vic_provinfo_tlv, value) +
VIC_PROVINFO_MAX_TLV_DATA) length > VIC_PROVINFO_MAX_TLV_DATA)
return -ENOMEM; return -ENOMEM;
tlv = (struct vic_provinfo_tlv *)((u8 *)vp->tlv + tlv = (struct vic_provinfo_tlv *)((u8 *)vp->tlv +
...@@ -66,7 +66,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length, ...@@ -66,7 +66,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
memcpy(tlv->value, value, length); memcpy(tlv->value, value, length);
vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1); vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1);
vp->length = htonl(ntohl(vp->length) + sizeof(*tlv) + length); vp->length = htonl(ntohl(vp->length) +
offsetof(struct vic_provinfo_tlv, value) + length);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment