diff options
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/netlink.c | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 6404052d6c07..8937664674fa 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -63,19 +63,23 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target, | |||
63 | 63 | ||
64 | genl_dump_check_consistent(cb, hdr, &nfc_genl_family); | 64 | genl_dump_check_consistent(cb, hdr, &nfc_genl_family); |
65 | 65 | ||
66 | NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx); | 66 | if (nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target->idx) || |
67 | NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols); | 67 | nla_put_u32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols) || |
68 | NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res); | 68 | nla_put_u16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res) || |
69 | NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res); | 69 | nla_put_u8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res)) |
70 | if (target->nfcid1_len > 0) | 70 | goto nla_put_failure; |
71 | NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, | 71 | if (target->nfcid1_len > 0 && |
72 | target->nfcid1); | 72 | nla_put(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, |
73 | if (target->sensb_res_len > 0) | 73 | target->nfcid1)) |
74 | NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len, | 74 | goto nla_put_failure; |
75 | target->sensb_res); | 75 | if (target->sensb_res_len > 0 && |
76 | if (target->sensf_res_len > 0) | 76 | nla_put(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len, |
77 | NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len, | 77 | target->sensb_res)) |
78 | target->sensf_res); | 78 | goto nla_put_failure; |
79 | if (target->sensf_res_len > 0 && | ||
80 | nla_put(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len, | ||
81 | target->sensf_res)) | ||
82 | goto nla_put_failure; | ||
79 | 83 | ||
80 | return genlmsg_end(msg, hdr); | 84 | return genlmsg_end(msg, hdr); |
81 | 85 | ||
@@ -170,7 +174,8 @@ int nfc_genl_targets_found(struct nfc_dev *dev) | |||
170 | if (!hdr) | 174 | if (!hdr) |
171 | goto free_msg; | 175 | goto free_msg; |
172 | 176 | ||
173 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 177 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) |
178 | goto nla_put_failure; | ||
174 | 179 | ||
175 | genlmsg_end(msg, hdr); | 180 | genlmsg_end(msg, hdr); |
176 | 181 | ||
@@ -197,10 +202,11 @@ int nfc_genl_device_added(struct nfc_dev *dev) | |||
197 | if (!hdr) | 202 | if (!hdr) |
198 | goto free_msg; | 203 | goto free_msg; |
199 | 204 | ||
200 | NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); | 205 | if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) || |
201 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 206 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) || |
202 | NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); | 207 | nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) || |
203 | NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up); | 208 | nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up)) |
209 | goto nla_put_failure; | ||
204 | 210 | ||
205 | genlmsg_end(msg, hdr); | 211 | genlmsg_end(msg, hdr); |
206 | 212 | ||
@@ -229,7 +235,8 @@ int nfc_genl_device_removed(struct nfc_dev *dev) | |||
229 | if (!hdr) | 235 | if (!hdr) |
230 | goto free_msg; | 236 | goto free_msg; |
231 | 237 | ||
232 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 238 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) |
239 | goto nla_put_failure; | ||
233 | 240 | ||
234 | genlmsg_end(msg, hdr); | 241 | genlmsg_end(msg, hdr); |
235 | 242 | ||
@@ -259,10 +266,11 @@ static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, | |||
259 | if (cb) | 266 | if (cb) |
260 | genl_dump_check_consistent(cb, hdr, &nfc_genl_family); | 267 | genl_dump_check_consistent(cb, hdr, &nfc_genl_family); |
261 | 268 | ||
262 | NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); | 269 | if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) || |
263 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 270 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) || |
264 | NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); | 271 | nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) || |
265 | NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up); | 272 | nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up)) |
273 | goto nla_put_failure; | ||
266 | 274 | ||
267 | return genlmsg_end(msg, hdr); | 275 | return genlmsg_end(msg, hdr); |
268 | 276 | ||
@@ -339,11 +347,14 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, | |||
339 | if (!hdr) | 347 | if (!hdr) |
340 | goto free_msg; | 348 | goto free_msg; |
341 | 349 | ||
342 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 350 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) |
343 | if (rf_mode == NFC_RF_INITIATOR) | 351 | goto nla_put_failure; |
344 | NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx); | 352 | if (rf_mode == NFC_RF_INITIATOR && |
345 | NLA_PUT_U8(msg, NFC_ATTR_COMM_MODE, comm_mode); | 353 | nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target_idx)) |
346 | NLA_PUT_U8(msg, NFC_ATTR_RF_MODE, rf_mode); | 354 | goto nla_put_failure; |
355 | if (nla_put_u8(msg, NFC_ATTR_COMM_MODE, comm_mode) || | ||
356 | nla_put_u8(msg, NFC_ATTR_RF_MODE, rf_mode)) | ||
357 | goto nla_put_failure; | ||
347 | 358 | ||
348 | genlmsg_end(msg, hdr); | 359 | genlmsg_end(msg, hdr); |
349 | 360 | ||
@@ -376,7 +387,8 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev) | |||
376 | if (!hdr) | 387 | if (!hdr) |
377 | goto free_msg; | 388 | goto free_msg; |
378 | 389 | ||
379 | NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); | 390 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) |
391 | goto nla_put_failure; | ||
380 | 392 | ||
381 | genlmsg_end(msg, hdr); | 393 | genlmsg_end(msg, hdr); |
382 | 394 | ||