Commit 3143a4ca610d6a3de0d8814ee6f5f7da6fc7fbfa

Authored by Axel Lin
Committed by Samuel Ortiz
1 parent 365a721adb

NFC: Move checking valid gb_len value to nfc_llcp_set_remote_gb

This checking is common for all caller, so move the checking to one place.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 2 changed files with 5 additions and 6 deletions Side-by-side Diff

... ... @@ -652,9 +652,6 @@
652 652 {
653 653 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
654 654  
655   - if (gb_len > NFC_MAX_GT_LEN)
656   - return -EINVAL;
657   -
658 655 return nfc_llcp_set_remote_gb(dev, gb, gb_len);
659 656 }
660 657 EXPORT_SYMBOL(nfc_set_remote_general_bytes);
... ... @@ -609,14 +609,16 @@
609 609  
610 610 int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
611 611 {
612   - struct nfc_llcp_local *local = nfc_llcp_find_local(dev);
  612 + struct nfc_llcp_local *local;
613 613  
  614 + if (gb_len < 3 || gb_len > NFC_MAX_GT_LEN)
  615 + return -EINVAL;
  616 +
  617 + local = nfc_llcp_find_local(dev);
614 618 if (local == NULL) {
615 619 pr_err("No LLCP device\n");
616 620 return -ENODEV;
617 621 }
618   - if (gb_len < 3)
619   - return -EINVAL;
620 622  
621 623 memset(local->remote_gb, 0, NFC_MAX_GT_LEN);
622 624 memcpy(local->remote_gb, gb, gb_len);