diff mbox

net: ethernet: fix call_kern.cocci warnings

Message ID alpine.DEB.2.20.1712170739410.2501@hadrien (mailing list archive)
State New, archived
Headers show

Commit Message

Julia Lawall Dec. 17, 2017, 6:43 a.m. UTC
From: Fengguang Wu <fengguang.wu@intel.com>

Allocation with GFP_KERNEL in code called from the function
geth_resize_freeq with locks held.

Generated by: scripts/coccinelle/locks/call_kern.cocci

Fixes: 502a2864e5e4 ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
---

 The proposed change of converting the GFP_KERNEL is not necessarily the
 correct one.  It may be desired to unlock the lock, or to not call the
 function under the lock in the first place.

tree:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git
gemini-ethernet
head:   502a2864e5e43c51a3a2689586d9c61d060a3b7d
commit: 502a2864e5e43c51a3a2689586d9c61d060a3b7d [18/18] net: ethernet:
Add a driver for Gemini gigabit ethernet

 gemini.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Linus Walleij Dec. 17, 2017, 10:47 p.m. UTC | #1
On Sun, Dec 17, 2017 at 7:43 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:

> From: Fengguang Wu <fengguang.wu@intel.com>
>
> Allocation with GFP_KERNEL in code called from the function
> geth_resize_freeq with locks held.
>
> Generated by: scripts/coccinelle/locks/call_kern.cocci
>
> Fixes: 502a2864e5e4 ("net: ethernet: Add a driver for Gemini gigabit ethernet")
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
>
>  The proposed change of converting the GFP_KERNEL is not necessarily the
>  correct one.  It may be desired to unlock the lock, or to not call the
>  function under the lock in the first place.

It's better to drop the lock around the offending call. the lock was just there
to protect the interrupt registers anyway.

But thanks for finding it!

I have updated the driver patch.

Yours,
Linus Walleij
diff mbox

Patch

--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -818,7 +818,7 @@  static int geth_setup_freeq(struct gemin

 	geth->freeq_ring = dma_alloc_coherent(geth->dev,
 		sizeof(*geth->freeq_ring) << geth->freeq_order,
-		&geth->freeq_dma_base, GFP_KERNEL);
+		&geth->freeq_dma_base, GFP_ATOMIC);
 	if (!geth->freeq_ring)
 		return -ENOMEM;
 	if (geth->freeq_dma_base & ~DMA_Q_BASE_MASK) {
@@ -827,7 +827,7 @@  static int geth_setup_freeq(struct gemin
 	}

 	geth->freeq_page_tab = kzalloc(pages * sizeof(*geth->freeq_page_tab),
-				       GFP_KERNEL);
+				       GFP_ATOMIC);
 	if (!geth->freeq_page_tab)
 		goto err_freeq;