Skip to content

Commit bd4217c

Browse files
ajaykathatgregkh
authored andcommitted
staging: wilc1000: avoid mutex unlock without lock in wilc_wlan_handle_txq()
In wilc_wlan_handle_txq(), mutex unlock was called without acquiring it. Also error code for full VMM condition was incorrect as discussed in [1]. Now used a proper code to indicate VMM is full, for which transfer to VMM is required again. 'wilc_wlan_handle_txq()' should be called again if the VMM space was full earlier or otherwise based on 'txq_event' signal. 1. https://lore.kernel.org/driverdev-devel/[email protected]/ Signed-off-by: Ajay Singh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7a80aa2 commit bd4217c

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

drivers/staging/wilc1000/netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int wilc_txq_task(void *vp)
174174
}
175175
srcu_read_unlock(&wl->srcu, srcu_idx);
176176
}
177-
} while (ret == -ENOBUFS && !wl->close);
177+
} while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close);
178178
}
179179
return 0;
180180
}

drivers/staging/wilc1000/wlan.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
489489
struct wilc_vif *vif;
490490

491491
if (wilc->quit)
492-
goto out;
492+
goto out_update_cnt;
493493

494494
mutex_lock(&wilc->txq_add_to_head_cs);
495495
tqe = wilc_wlan_txq_get_first(wilc);
496496
if (!tqe)
497-
goto out;
497+
goto out_unlock;
498498
dev = tqe->vif->ndev;
499499
wilc_wlan_txq_filter_dup_tcp_ack(dev);
500500
i = 0;
@@ -526,7 +526,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
526526
}
527527

528528
if (i == 0)
529-
goto out;
529+
goto out_unlock;
530530
vmm_table[i] = 0x0;
531531

532532
acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
@@ -595,7 +595,11 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
595595
goto out_release_bus;
596596

597597
if (entries == 0) {
598-
ret = -ENOBUFS;
598+
/*
599+
* No VMM space available in firmware so retry to transmit
600+
* the packet from tx queue.
601+
*/
602+
ret = WILC_VMM_ENTRY_FULL_RETRY;
599603
goto out_release_bus;
600604
}
601605

@@ -662,9 +666,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
662666
out_release_bus:
663667
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
664668

665-
out:
669+
out_unlock:
666670
mutex_unlock(&wilc->txq_add_to_head_cs);
667671

672+
out_update_cnt:
668673
*txq_count = wilc->txq_entries;
669674
return ret;
670675
}

drivers/staging/wilc1000/wlan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
#define IS_MGMT_STATUS_SUCCES 0x040
199199

200200
#define WILC_WID_TYPE GENMASK(15, 12)
201+
#define WILC_VMM_ENTRY_FULL_RETRY 1
201202
/********************************************
202203
*
203204
* Tx/Rx Queue Structure

0 commit comments

Comments
 (0)