NFC: Do not return EBUSY when stopping a poll that's already stopped
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 28 Jun 2012 14:41:57 +0000 (16:41 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 9 Jul 2012 20:42:21 +0000 (16:42 -0400)
We check for the polling flag before checking if the netlink PID caller
match.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/netlink.c

index 03c31db38f1284dbceed6cb57a97ab8ec0bd13ab..99bc6f7faa7b858e28254b3690ca46b1592d24fb 100644 (file)
@@ -634,6 +634,15 @@ static int nfc_genl_stop_poll(struct sk_buff *skb, struct genl_info *info)
        if (!dev)
                return -ENODEV;
 
+       device_lock(&dev->dev);
+
+       if (!dev->polling) {
+               device_unlock(&dev->dev);
+               return -EINVAL;
+       }
+
+       device_unlock(&dev->dev);
+
        mutex_lock(&dev->genl_data.genl_data_mutex);
 
        if (dev->genl_data.poll_req_pid != info->snd_pid) {