diff mbox series

[bringup,3/3] ath11k: Use struct_size() to get the structure size with trailing array

Message ID 1569386658-1325-3-git-send-email-vthiagar@codeaurora.org (mailing list archive)
State Accepted
Commit 3dcb3e76a2601ea7c662585b6450d035e16cb9a9
Delegated to: Kalle Valo
Headers show
Series [bringup,1/3] ath11k: Clean ups in ath11k_ce_rx_buf_enqueue_pipe() error path | expand

Commit Message

Vasanthakumar Thiagarajan Sept. 25, 2019, 4:44 a.m. UTC
The size calculation of struct ath11k_ce_ring with trailing skb array
got simplified with struct_size() kernel macro.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/ce.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/ce.c b/drivers/net/wireless/ath/ath11k/ce.c
index 03e7cf0..daeab0f 100644
--- a/drivers/net/wireless/ath/ath11k/ce.c
+++ b/drivers/net/wireless/ath/ath11k/ce.c
@@ -406,8 +406,7 @@  static int ath11k_ce_init_ring(struct ath11k_base *ab,
 	struct ath11k_ce_ring *ce_ring;
 	dma_addr_t base_addr;
 
-	ce_ring = kzalloc(sizeof(*ce_ring) + (nentries * sizeof(*ce_ring->skb)),
-			  GFP_KERNEL);
+	ce_ring = kzalloc(struct_size(ce_ring, skb, nentries), GFP_KERNEL);
 	if (ce_ring == NULL)
 		return ERR_PTR(-ENOMEM);