net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver
Hello Łukasz Stelmach,
The patch a97c69ba4f30: "net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver" from Oct 20, 2021, leads to the following Smatch static checker warning:
drivers/net/ethernet/asix/ax88796c_main.c:391 ax88796c_start_xmit() warn: test_bit() takes a bit number
drivers/net/ethernet/asix/ax88796c_main.c
382 static int
383 ax88796c_start_xmit(struct sk_buff *skb, struct net_device *ndev)
384 {
385 struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
386
387 skb_queue_tail(&ax_local->tx_wait_q, skb);
388 if (skb_queue_len(&ax_local->tx_wait_q) > TX_QUEUE_HIGH_WATER)
389 netif_stop_queue(ndev);
390 --> 391 set_bit(EVENT_TX, &ax_local->flags);
EVENT_TX is BIT(1) so this ends up being a double BIT(BIT(1));. Which is fine because it seems to be done consistently. But probably it should be:
#define EVENT_INTR 0
#define EVENT_TX 1
#define EVENT_SET_MULTI 2
392 schedule_work(&ax_local->ax_work);
393
394 return NETDEV_TX_OK;
395 }regards,
dan carpenter
Quoted 21 lines · when Dan Carpenter
Hello Łukasz Stelmach,
The patch
a97c69ba4f30: "net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver" from Oct 20, 2021, leads to the following Smatch static checker warning:drivers/net/ethernet/asix/ax88796c_main.c:391 ax88796c_start_xmit() warn: test_bit() takes a bit number
drivers/net/ethernet/asix/ax88796c_main.c382 static int 383 ax88796c_start_xmit(struct sk_buff *skb, struct net_device *ndev) 384 { 385 struct ax88796c_device *ax_local = to_ax88796c_device(ndev); 386 387 skb_queue_tail(&ax_local->tx_wait_q, skb); 388 if (skb_queue_len(&ax_local->tx_wait_q) > TX_QUEUE_HIGH_WATER) 389 netif_stop_queue(ndev); 390--> 391
set_bit(EVENT_TX, &ax_local->flags);
Quoted 8 lines
EVENT_TXis BIT(1) so this ends up being a double BIT(BIT(1));. Which is fine because it seems to be done consistently. But probably it should be:#define
EVENT_INTR0
#defineEVENT_TX1
#defineEVENT_SET_MULTI2
Apparently this is a porting artifact. Originally these were defined as {1,2,4}[1] so I changed that to BIT(x) without much consideration. I am fixing it. Thanks for reporting.
Quoted 9 lines
392 schedule_work(&ax_local->ax_work); 393 394 return NETDEV_TX_OK; 395 }regards,
dan carpenter
[1] https://lore.kernel.org/lkml/[email protected]/
Signature · 3 lines
Łukasz Stelmach Samsung R&D Institute Poland Samsung Electronics
Quoted 26 lines · Lukasz Stelmach
Quoted 25 lines · when Dan Carpenter
Hello Łukasz Stelmach,
The patch
a97c69ba4f30: "net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver" from Oct 20, 2021, leads to the following Smatch static checker warning:drivers/net/ethernet/asix/ax88796c_main.c:391 ax88796c_start_xmit() warn: test_bit() takes a bit number
drivers/net/ethernet/asix/ax88796c_main.c382 static int 383 ax88796c_start_xmit(struct sk_buff *skb, struct net_device *ndev) 384 { 385 struct ax88796c_device *ax_local = to_ax88796c_device(ndev); 386 387 skb_queue_tail(&ax_local->tx_wait_q, skb); 388 if (skb_queue_len(&ax_local->tx_wait_q) > TX_QUEUE_HIGH_WATER) 389 netif_stop_queue(ndev); 390--> 391
set_bit(EVENT_TX, &ax_local->flags);
EVENT_TXis BIT(1) so this ends up being a double BIT(BIT(1));. Which is fine because it seems to be done consistently. But probably it should be:
Quoted 8 lines
Quoted 4 lines
#define
EVENT_INTR0
#defineEVENT_TX1
#defineEVENT_SET_MULTI2Apparently this is a porting artifact. Originally these were defined as {1,2,4}[1] so I changed that to BIT(x) without much consideration. I am fixing it. Thanks for reporting.
Changing it back to 1,2,4 will hide bug from the Smatch but the correct values are 0,1,2.
regards,
dan carpenter