aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/enic/vnic_vic.c
diff options
context:
space:
mode:
authorRoopa Prabhu <roprabhu@cisco.com>2010-08-10 14:55:10 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-17 05:32:58 -0400
commit7c46835e4845fed5f348f5845a3a6165874e2f05 (patch)
tree7ddc9fb2de9ba71a8904452160685a74c5bd8cff /drivers/net/enic/vnic_vic.c
parentae94abe1687871d9772494b3d378c6d3decd7f75 (diff)
enic: Use offsetof macro in vic tlv length calculation
Signed-off-by: Scott Feldman <scofeldm@cisco.com> Signed-off-by: Roopa Prabhu <roprabhu@cisco.com> Signed-off-by: Vasanthy Kolluri <vkolluri@cisco.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/enic/vnic_vic.c')
-rw-r--r--drivers/net/enic/vnic_vic.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/enic/vnic_vic.c b/drivers/net/enic/vnic_vic.c
index 197c9d24af82..4725b79de0ef 100644
--- a/drivers/net/enic/vnic_vic.c
+++ b/drivers/net/enic/vnic_vic.c
@@ -54,8 +54,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
54 if (!vp || !value) 54 if (!vp || !value)
55 return -EINVAL; 55 return -EINVAL;
56 56
57 if (ntohl(vp->length) + sizeof(*tlv) + length > 57 if (ntohl(vp->length) + offsetof(struct vic_provinfo_tlv, value) +
58 VIC_PROVINFO_MAX_TLV_DATA) 58 length > VIC_PROVINFO_MAX_TLV_DATA)
59 return -ENOMEM; 59 return -ENOMEM;
60 60
61 tlv = (struct vic_provinfo_tlv *)((u8 *)vp->tlv + 61 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 memcpy(tlv->value, value, length); 66 memcpy(tlv->value, value, length);
67 67
68 vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1); 68 vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1);
69 vp->length = htonl(ntohl(vp->length) + sizeof(*tlv) + length); 69 vp->length = htonl(ntohl(vp->length) +
70 offsetof(struct vic_provinfo_tlv, value) + length);
70 71
71 return 0; 72 return 0;
72} 73}