diff options
author | Chuhong Yuan <hslester96@gmail.com> | 2019-07-16 22:05:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-07-18 19:31:27 -0400 |
commit | 8ec1e9006908a606b2a67c905f33ee2d3b6be5c2 (patch) | |
tree | ab18fcdc9f64a0a839cdbe9daed1265671f3ace6 | |
parent | bb745231678cd92ab0c4d37343b06e4879072368 (diff) |
gve: replace kfree with kvfree
Variables allocated by kvzalloc should not be freed by kfree.
Because they may be allocated by vmalloc.
So we replace kfree with kvfree here.
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/google/gve/gve_main.c | 22 | ||||
-rw-r--r-- | drivers/net/ethernet/google/gve/gve_rx.c | 4 |
2 files changed, 13 insertions, 13 deletions
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index e8ee8cac2bbf..497298752381 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c | |||
@@ -232,7 +232,7 @@ abort_with_mgmt_vector: | |||
232 | abort_with_msix_enabled: | 232 | abort_with_msix_enabled: |
233 | pci_disable_msix(priv->pdev); | 233 | pci_disable_msix(priv->pdev); |
234 | abort_with_msix_vectors: | 234 | abort_with_msix_vectors: |
235 | kfree(priv->msix_vectors); | 235 | kvfree(priv->msix_vectors); |
236 | priv->msix_vectors = NULL; | 236 | priv->msix_vectors = NULL; |
237 | return err; | 237 | return err; |
238 | } | 238 | } |
@@ -256,7 +256,7 @@ static void gve_free_notify_blocks(struct gve_priv *priv) | |||
256 | priv->ntfy_blocks = NULL; | 256 | priv->ntfy_blocks = NULL; |
257 | free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); | 257 | free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); |
258 | pci_disable_msix(priv->pdev); | 258 | pci_disable_msix(priv->pdev); |
259 | kfree(priv->msix_vectors); | 259 | kvfree(priv->msix_vectors); |
260 | priv->msix_vectors = NULL; | 260 | priv->msix_vectors = NULL; |
261 | } | 261 | } |
262 | 262 | ||
@@ -445,12 +445,12 @@ static int gve_alloc_rings(struct gve_priv *priv) | |||
445 | return 0; | 445 | return 0; |
446 | 446 | ||
447 | free_rx: | 447 | free_rx: |
448 | kfree(priv->rx); | 448 | kvfree(priv->rx); |
449 | priv->rx = NULL; | 449 | priv->rx = NULL; |
450 | free_tx_queue: | 450 | free_tx_queue: |
451 | gve_tx_free_rings(priv); | 451 | gve_tx_free_rings(priv); |
452 | free_tx: | 452 | free_tx: |
453 | kfree(priv->tx); | 453 | kvfree(priv->tx); |
454 | priv->tx = NULL; | 454 | priv->tx = NULL; |
455 | return err; | 455 | return err; |
456 | } | 456 | } |
@@ -500,7 +500,7 @@ static void gve_free_rings(struct gve_priv *priv) | |||
500 | gve_remove_napi(priv, ntfy_idx); | 500 | gve_remove_napi(priv, ntfy_idx); |
501 | } | 501 | } |
502 | gve_tx_free_rings(priv); | 502 | gve_tx_free_rings(priv); |
503 | kfree(priv->tx); | 503 | kvfree(priv->tx); |
504 | priv->tx = NULL; | 504 | priv->tx = NULL; |
505 | } | 505 | } |
506 | if (priv->rx) { | 506 | if (priv->rx) { |
@@ -509,7 +509,7 @@ static void gve_free_rings(struct gve_priv *priv) | |||
509 | gve_remove_napi(priv, ntfy_idx); | 509 | gve_remove_napi(priv, ntfy_idx); |
510 | } | 510 | } |
511 | gve_rx_free_rings(priv); | 511 | gve_rx_free_rings(priv); |
512 | kfree(priv->rx); | 512 | kvfree(priv->rx); |
513 | priv->rx = NULL; | 513 | priv->rx = NULL; |
514 | } | 514 | } |
515 | } | 515 | } |
@@ -592,9 +592,9 @@ static void gve_free_queue_page_list(struct gve_priv *priv, | |||
592 | gve_free_page(&priv->pdev->dev, qpl->pages[i], | 592 | gve_free_page(&priv->pdev->dev, qpl->pages[i], |
593 | qpl->page_buses[i], gve_qpl_dma_dir(priv, id)); | 593 | qpl->page_buses[i], gve_qpl_dma_dir(priv, id)); |
594 | 594 | ||
595 | kfree(qpl->page_buses); | 595 | kvfree(qpl->page_buses); |
596 | free_pages: | 596 | free_pages: |
597 | kfree(qpl->pages); | 597 | kvfree(qpl->pages); |
598 | priv->num_registered_pages -= qpl->num_entries; | 598 | priv->num_registered_pages -= qpl->num_entries; |
599 | } | 599 | } |
600 | 600 | ||
@@ -635,7 +635,7 @@ static int gve_alloc_qpls(struct gve_priv *priv) | |||
635 | free_qpls: | 635 | free_qpls: |
636 | for (j = 0; j <= i; j++) | 636 | for (j = 0; j <= i; j++) |
637 | gve_free_queue_page_list(priv, j); | 637 | gve_free_queue_page_list(priv, j); |
638 | kfree(priv->qpls); | 638 | kvfree(priv->qpls); |
639 | return err; | 639 | return err; |
640 | } | 640 | } |
641 | 641 | ||
@@ -644,12 +644,12 @@ static void gve_free_qpls(struct gve_priv *priv) | |||
644 | int num_qpls = gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv); | 644 | int num_qpls = gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv); |
645 | int i; | 645 | int i; |
646 | 646 | ||
647 | kfree(priv->qpl_cfg.qpl_id_map); | 647 | kvfree(priv->qpl_cfg.qpl_id_map); |
648 | 648 | ||
649 | for (i = 0; i < num_qpls; i++) | 649 | for (i = 0; i < num_qpls; i++) |
650 | gve_free_queue_page_list(priv, i); | 650 | gve_free_queue_page_list(priv, i); |
651 | 651 | ||
652 | kfree(priv->qpls); | 652 | kvfree(priv->qpls); |
653 | } | 653 | } |
654 | 654 | ||
655 | /* Use this to schedule a reset when the device is capable of continuing | 655 | /* Use this to schedule a reset when the device is capable of continuing |
diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/ethernet/google/gve/gve_rx.c index c1aeabd1c594..1914b8350da7 100644 --- a/drivers/net/ethernet/google/gve/gve_rx.c +++ b/drivers/net/ethernet/google/gve/gve_rx.c | |||
@@ -35,7 +35,7 @@ static void gve_rx_free_ring(struct gve_priv *priv, int idx) | |||
35 | 35 | ||
36 | gve_unassign_qpl(priv, rx->data.qpl->id); | 36 | gve_unassign_qpl(priv, rx->data.qpl->id); |
37 | rx->data.qpl = NULL; | 37 | rx->data.qpl = NULL; |
38 | kfree(rx->data.page_info); | 38 | kvfree(rx->data.page_info); |
39 | 39 | ||
40 | slots = rx->data.mask + 1; | 40 | slots = rx->data.mask + 1; |
41 | bytes = sizeof(*rx->data.data_ring) * slots; | 41 | bytes = sizeof(*rx->data.data_ring) * slots; |
@@ -168,7 +168,7 @@ abort_with_q_resources: | |||
168 | rx->q_resources, rx->q_resources_bus); | 168 | rx->q_resources, rx->q_resources_bus); |
169 | rx->q_resources = NULL; | 169 | rx->q_resources = NULL; |
170 | abort_filled: | 170 | abort_filled: |
171 | kfree(rx->data.page_info); | 171 | kvfree(rx->data.page_info); |
172 | abort_with_slots: | 172 | abort_with_slots: |
173 | bytes = sizeof(*rx->data.data_ring) * slots; | 173 | bytes = sizeof(*rx->data.data_ring) * slots; |
174 | dma_free_coherent(hdev, bytes, rx->data.data_ring, rx->data.data_bus); | 174 | dma_free_coherent(hdev, bytes, rx->data.data_ring, rx->data.data_bus); |