NFC: Fix empty HCI message list check
authorMathias Jeppsson <mathias.jeppsson@sonymobile.com>
Fri, 6 Jul 2012 22:53:18 +0000 (00:53 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 10 Jul 2012 15:42:50 +0000 (11:42 -0400)
list_first_entry() will never return NULL. Instead use
list_for_each_entry_safe() to iterate through the list.

Signed-off-by: Mathias Jeppsson <mathias.jeppsson@sonymobile.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/nfc/hci/core.c

index e1a640d2b588eedbe4f0a32b8f24cbfb74b1ff64..da6e039c86063b5c96971f63b31162dfe57eb4dd 100644 (file)
@@ -682,13 +682,12 @@ EXPORT_SYMBOL(nfc_hci_register_device);
 
 void nfc_hci_unregister_device(struct nfc_hci_dev *hdev)
 {
-       struct hci_msg *msg;
+       struct hci_msg *msg, *n;
 
        skb_queue_purge(&hdev->rx_hcp_frags);
        skb_queue_purge(&hdev->msg_rx_queue);
 
-       while ((msg = list_first_entry(&hdev->msg_tx_queue, struct hci_msg,
-                                      msg_l)) != NULL) {
+       list_for_each_entry_safe(msg, n, &hdev->msg_tx_queue, msg_l) {
                list_del(&msg->msg_l);
                skb_queue_purge(&msg->msg_frags);
                kfree(msg);