diff mbox series

[net-next] liquidio: Replace vmalloc with kmalloc in octeon_register_dispatch_fn()

Message ID 20200730061140.20223-1-wanghai38@huawei.com
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] liquidio: Replace vmalloc with kmalloc in octeon_register_dispatch_fn() | expand

Commit Message

Wang Hai July 30, 2020, 6:11 a.m. UTC
The size of struct octeon_dispatch is too small, it is better to use
kmalloc instead of vmalloc.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

David Miller July 31, 2020, 12:40 a.m. UTC | #1
From: Wang Hai <wanghai38@huawei.com>
Date: Thu, 30 Jul 2020 14:11:40 +0800

> The size of struct octeon_dispatch is too small, it is better to use
> kmalloc instead of vmalloc.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index 934115d18488..ac32facaa427 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -1056,7 +1056,7 @@  void octeon_delete_dispatch_list(struct octeon_device *oct)
 
 	list_for_each_safe(temp, tmp2, &freelist) {
 		list_del(temp);
-		vfree(temp);
+		kfree(temp);
 	}
 }
 
@@ -1152,13 +1152,10 @@  octeon_register_dispatch_fn(struct octeon_device *oct,
 
 		dev_dbg(&oct->pci_dev->dev,
 			"Adding opcode to dispatch list linked list\n");
-		dispatch = (struct octeon_dispatch *)
-			   vmalloc(sizeof(struct octeon_dispatch));
-		if (!dispatch) {
-			dev_err(&oct->pci_dev->dev,
-				"No memory to add dispatch function\n");
+		dispatch = kmalloc(sizeof(*dispatch), GFP_KERNEL);
+		if (!dispatch)
 			return 1;
-		}
+
 		dispatch->opcode = combined_opcode;
 		dispatch->dispatch_fn = fn;
 		dispatch->arg = fn_arg;