Skip to content

Commit 8b6237e

Browse files
Yue Haibingkuba-moo
authored andcommitted
igc: Fix passing 0 to ERR_PTR in igc_xdp_run_prog()
igc_xdp_run_prog() converts customed xdp action to a negative error code with the sk_buff pointer type which be checked with IS_ERR in igc_clean_rx_irq(). Remove this error pointer handing instead use plain int return value to fix this smatch warnings: drivers/net/ethernet/intel/igc/igc_main.c:2533 igc_xdp_run_prog() warn: passing zero to 'ERR_PTR' Reviewed-by: Maciej Fijalkowski <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Yue Haibing <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Avigail Dahan <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 484d367 commit 8b6237e

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,10 +2123,6 @@ static bool igc_cleanup_headers(struct igc_ring *rx_ring,
21232123
union igc_adv_rx_desc *rx_desc,
21242124
struct sk_buff *skb)
21252125
{
2126-
/* XDP packets use error pointer so abort at this point */
2127-
if (IS_ERR(skb))
2128-
return true;
2129-
21302126
if (unlikely(igc_test_staterr(rx_desc, IGC_RXDEXT_STATERR_RXE))) {
21312127
struct net_device *netdev = rx_ring->netdev;
21322128

@@ -2515,8 +2511,7 @@ static int __igc_xdp_run_prog(struct igc_adapter *adapter,
25152511
}
25162512
}
25172513

2518-
static struct sk_buff *igc_xdp_run_prog(struct igc_adapter *adapter,
2519-
struct xdp_buff *xdp)
2514+
static int igc_xdp_run_prog(struct igc_adapter *adapter, struct xdp_buff *xdp)
25202515
{
25212516
struct bpf_prog *prog;
25222517
int res;
@@ -2530,7 +2525,7 @@ static struct sk_buff *igc_xdp_run_prog(struct igc_adapter *adapter,
25302525
res = __igc_xdp_run_prog(adapter, prog, xdp);
25312526

25322527
out:
2533-
return ERR_PTR(-res);
2528+
return res;
25342529
}
25352530

25362531
/* This function assumes __netif_tx_lock is held by the caller. */
@@ -2585,6 +2580,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
25852580
struct sk_buff *skb = rx_ring->skb;
25862581
u16 cleaned_count = igc_desc_unused(rx_ring);
25872582
int xdp_status = 0, rx_buffer_pgcnt;
2583+
int xdp_res = 0;
25882584

25892585
while (likely(total_packets < budget)) {
25902586
struct igc_xdp_buff ctx = { .rx_ts = NULL };
@@ -2630,12 +2626,10 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
26302626
xdp_buff_clear_frags_flag(&ctx.xdp);
26312627
ctx.rx_desc = rx_desc;
26322628

2633-
skb = igc_xdp_run_prog(adapter, &ctx.xdp);
2629+
xdp_res = igc_xdp_run_prog(adapter, &ctx.xdp);
26342630
}
26352631

2636-
if (IS_ERR(skb)) {
2637-
unsigned int xdp_res = -PTR_ERR(skb);
2638-
2632+
if (xdp_res) {
26392633
switch (xdp_res) {
26402634
case IGC_XDP_CONSUMED:
26412635
rx_buffer->pagecnt_bias++;
@@ -2657,7 +2651,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
26572651
skb = igc_construct_skb(rx_ring, rx_buffer, &ctx);
26582652

26592653
/* exit if we failed to retrieve a buffer */
2660-
if (!skb) {
2654+
if (!xdp_res && !skb) {
26612655
rx_ring->rx_stats.alloc_failed++;
26622656
rx_buffer->pagecnt_bias++;
26632657
set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
@@ -2672,7 +2666,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
26722666
continue;
26732667

26742668
/* verify the packet layout is correct */
2675-
if (igc_cleanup_headers(rx_ring, rx_desc, skb)) {
2669+
if (xdp_res || igc_cleanup_headers(rx_ring, rx_desc, skb)) {
26762670
skb = NULL;
26772671
continue;
26782672
}

0 commit comments

Comments
 (0)