aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-02-24 20:18:10 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2014-03-14 15:19:08 -0400
commit3143a4ca610d6a3de0d8814ee6f5f7da6fc7fbfa (patch)
tree434e24069b2b015d49981b8d11314e905c1966c6 /net/nfc
parent365a721adbdfe5f6577a66b9b74c12dc98fbb4a3 (diff)
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>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/core.c3
-rw-r--r--net/nfc/llcp_core.c8
2 files changed, 5 insertions, 6 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index be5d50c6d81d..819b87702b70 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -652,9 +652,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
652{ 652{
653 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len); 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 return nfc_llcp_set_remote_gb(dev, gb, gb_len); 655 return nfc_llcp_set_remote_gb(dev, gb, gb_len);
659} 656}
660EXPORT_SYMBOL(nfc_set_remote_general_bytes); 657EXPORT_SYMBOL(nfc_set_remote_general_bytes);
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 9d37dedec906..0cf9d4f45e6a 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -609,14 +609,16 @@ u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len)
609 609
610int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) 610int 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
614 if (gb_len < 3 || gb_len > NFC_MAX_GT_LEN)
615 return -EINVAL;
613 616
617 local = nfc_llcp_find_local(dev);
614 if (local == NULL) { 618 if (local == NULL) {
615 pr_err("No LLCP device\n"); 619 pr_err("No LLCP device\n");
616 return -ENODEV; 620 return -ENODEV;
617 } 621 }
618 if (gb_len < 3)
619 return -EINVAL;
620 622
621 memset(local->remote_gb, 0, NFC_MAX_GT_LEN); 623 memset(local->remote_gb, 0, NFC_MAX_GT_LEN);
622 memcpy(local->remote_gb, gb, gb_len); 624 memcpy(local->remote_gb, gb, gb_len);