i40e: add an error handling path in i40e_xsk_pool_enable()

Started by Haoxiang Li on Jan 31, 2026 · 8 messages from 4 authors · Last reply Sep 15, 2026

Subsystems (3)

Maintainers (8)

Show 4 more
COLD59d

open the first message on its own page

Message details and related content
In i40e_xsk_pool_enable(), add an error handling path to
prevent potential memory leaks.

Fixes: 1742b3d52869 ("xsk: i40e: ice: ixgbe: mlx5: Pass buffer pool to driver instead of umem")
Cc: <redacted>
Signed-off-by: Haoxiang Li <redacted>
---
Changes in v2:
- Add a Fixes tag. Thanks, Paul!
- Replace unmap with i40e_xsk_pool_disable() to prevent
a limbo state of queues. Thanks, Maciej! 
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 9f47388eaba5..a72a309540c3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -108,23 +108,26 @@ static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
 	if (if_running) {
 		err = i40e_queue_pair_disable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], true);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_queue_pair_enable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		/* Kick start the NAPI context so that receiving will start */
 		err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
 		if (err)
-			return err;
+			goto err_out;
 	}
 
 	return 0;
+
+err_out:
+	i40e_xsk_pool_disable(vsi, qid);
 }
 
 /**
-- 
2.25.1

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in

Message details and related content
On Sat, 31 Jan 2026 13:52:17 +0800, Haoxiang Li wrote:
quoted hunk
In i40e_xsk_pool_enable(), add an error handling path to
prevent potential memory leaks.

Fixes: 1742b3d52869 ("xsk: i40e: ice: ixgbe: mlx5: Pass buffer pool to driver instead of umem")
Cc: <redacted>
Signed-off-by: Haoxiang Li <redacted>
---
Changes in v2:
- Add a Fixes tag. Thanks, Paul!
- Replace unmap with i40e_xsk_pool_disable() to prevent
a limbo state of queues. Thanks, Maciej! 
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 9f47388eaba5..a72a309540c3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -108,23 +108,26 @@ static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
 	if (if_running) {
 		err = i40e_queue_pair_disable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], true);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_queue_pair_enable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		/* Kick start the NAPI context so that receiving will start */
 		err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
 		if (err)
-			return err;

7 more quoted lines

I think return err; is missing...

Also, since i40e_xsk_pool_disable is not declared before this line,
compilation fails due to a 'Call to undeclared function
i40e_xsk_pool_disable' error. Adding declaration or moving
i40e_xsk_pool_enable() after i40e_xsk_pool_disable() is needed.
 }
 
 /**
-- 
2.25.1

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in

Message details and related content
On Sat, 31 Jan 2026 06:12:12 +0000, Kohei Enju wrote:
On Sat, 31 Jan 2026 13:52:17 +0800, Haoxiang Li wrote:
quoted
In i40e_xsk_pool_enable(), add an error handling path to
prevent potential memory leaks.

Fixes: 1742b3d52869 ("xsk: i40e: ice: ixgbe: mlx5: Pass buffer pool to driver instead of umem")
Cc: <redacted>
Signed-off-by: Haoxiang Li <redacted>
---
Changes in v2:
- Add a Fixes tag. Thanks, Paul!
- Replace unmap with i40e_xsk_pool_disable() to prevent
a limbo state of queues. Thanks, Maciej! 
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 9f47388eaba5..a72a309540c3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -108,23 +108,26 @@ static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
 	if (if_running) {
 		err = i40e_queue_pair_disable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], true);
 		if (err)
-			return err;
+			goto err_out;
 
 		err = i40e_queue_pair_enable(vsi, qid);
 		if (err)
-			return err;
+			goto err_out;
 
 		/* Kick start the NAPI context so that receiving will start */
 		err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);

16 more quoted lines

After skimming the code, I think i40e_xsk_pool_disable() can fail in
this error path, right? 

Let's assume a scenario that i40e_queue_pair_disable() succeeds but
i40e_realloc_rx_xdp_bi() fails in i40e_xsk_pool_enable(). 
At this point, i40e_enter_busy_conf() called by
i40e_queue_pair_disable() has set __I40E_CONFIG_BUSY state.

Then the err_out: path is executed and i40e_xsk_pool_disable() tries to
call i40e_queue_pair_disable() when if_running.
In this case, i40e_enter_busy_conf() fails because __I40E_CONFIG_BUSY is
set, and finally xsk_pool_dma_unmap() isn't called.

Do you have any thoughts on how to handle this case?

Thanks.
quoted
 }
 
 /**
-- 
2.25.1

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()

Message details and related content
Hi Haoxiang,

kernel test robot noticed the following build errors:

[auto build test ERROR on tnguy-next-queue/dev-queue]
[also build test ERROR on tnguy-net-queue/dev-queue linus/master v6.16-rc1 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/i40e-add-an-error-handling-path-in-i40e_xsk_pool_enable/20260131-135447
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link:    https://lore.kernel.org/r/20260131055217.729048-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()
config: x86_64-rhel-9.4-kunit (https://download.01.org/0day-ci/archive/20260131/202601311618.xd5faCRh-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260131/202601311618.xd5faCRh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot [off-list ref]
| Closes: https://lore.kernel.org/oe-kbuild-all/202601311618.xd5faCRh-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/i40e/i40e_xsk.c: In function 'i40e_xsk_pool_enable':
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: error: implicit declaration of function 'i40e_xsk_pool_disable'; did you mean 'i40e_xsk_pool_enable'? [-Wimplicit-function-declaration]
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         i40e_xsk_pool_enable
   drivers/net/ethernet/intel/i40e/i40e_xsk.c: At top level:
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:141:12: error: conflicting types for 'i40e_xsk_pool_disable'; have 'int(struct i40e_vsi *, u16)' {aka 'int(struct i40e_vsi *, short unsigned int)'}
     141 | static int i40e_xsk_pool_disable(struct i40e_vsi *vsi, u16 qid)
         |            ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:142:1: note: an argument type that has a default promotion cannot match an empty parameter name list declaration
     142 | {
         | ^
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: note: previous implicit declaration of 'i40e_xsk_pool_disable' with type 'int()'
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c: In function 'i40e_xsk_pool_enable':
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
     131 | }
         | ^


vim +130 drivers/net/ethernet/intel/i40e/i40e_xsk.c

    72	
    73	/**
    74	 * i40e_xsk_pool_enable - Enable/associate an AF_XDP buffer pool to a
    75	 * certain ring/qid
    76	 * @vsi: Current VSI
    77	 * @pool: buffer pool
    78	 * @qid: Rx ring to associate buffer pool with
    79	 *
    80	 * Returns 0 on success, <0 on failure
    81	 **/
    82	static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
    83					struct xsk_buff_pool *pool,
    84					u16 qid)
    85	{
    86		struct net_device *netdev = vsi->netdev;
    87		bool if_running;
    88		int err;
    89	
    90		if (vsi->type != I40E_VSI_MAIN)
    91			return -EINVAL;
    92	
    93		if (qid >= vsi->num_queue_pairs)
    94			return -EINVAL;
    95	
    96		if (qid >= netdev->real_num_rx_queues ||
    97		    qid >= netdev->real_num_tx_queues)
    98			return -EINVAL;
    99	
   100		err = xsk_pool_dma_map(pool, &vsi->back->pdev->dev, I40E_RX_DMA_ATTR);
   101		if (err)
   102			return err;
   103	
   104		set_bit(qid, vsi->af_xdp_zc_qps);
   105	

73 more lines

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()

Message details and related content
Hi Haoxiang,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tnguy-next-queue/dev-queue]
[also build test WARNING on tnguy-net-queue/dev-queue linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/i40e-add-an-error-handling-path-in-i40e_xsk_pool_enable/20260131-135447
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link:    https://lore.kernel.org/r/20260131055217.729048-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20260131/202601312359.c8Furmbm-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260131/202601312359.c8Furmbm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot [off-list ref]
| Closes: https://lore.kernel.org/oe-kbuild-all/202601312359.c8Furmbm-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/i40e/i40e_xsk.c: In function 'i40e_xsk_pool_enable':
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: error: implicit declaration of function 'i40e_xsk_pool_disable'; did you mean 'i40e_xsk_pool_enable'? [-Wimplicit-function-declaration]
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         i40e_xsk_pool_enable
   drivers/net/ethernet/intel/i40e/i40e_xsk.c: At top level:
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:141:12: error: conflicting types for 'i40e_xsk_pool_disable'; have 'int(struct i40e_vsi *, u16)' {aka 'int(struct i40e_vsi *, short unsigned int)'}
     141 | static int i40e_xsk_pool_disable(struct i40e_vsi *vsi, u16 qid)
         |            ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:142:1: note: an argument type that has a default promotion cannot match an empty parameter name list declaration
     142 | {
         | ^
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: note: previous implicit declaration of 'i40e_xsk_pool_disable' with type 'int()'
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~

1 more lines

quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
     131 | }
         | ^


vim +131 drivers/net/ethernet/intel/i40e/i40e_xsk.c

aae425efdfd1b1 Jan Sokolowski  2022-10-12   72  
0a714186d3c0f7 Björn Töpel     2018-08-28   73  /**
1742b3d528690a Magnus Karlsson 2020-08-28   74   * i40e_xsk_pool_enable - Enable/associate an AF_XDP buffer pool to a
1742b3d528690a Magnus Karlsson 2020-08-28   75   * certain ring/qid
0a714186d3c0f7 Björn Töpel     2018-08-28   76   * @vsi: Current VSI
1742b3d528690a Magnus Karlsson 2020-08-28   77   * @pool: buffer pool
1742b3d528690a Magnus Karlsson 2020-08-28   78   * @qid: Rx ring to associate buffer pool with
0a714186d3c0f7 Björn Töpel     2018-08-28   79   *
0a714186d3c0f7 Björn Töpel     2018-08-28   80   * Returns 0 on success, <0 on failure
0a714186d3c0f7 Björn Töpel     2018-08-28   81   **/
1742b3d528690a Magnus Karlsson 2020-08-28   82  static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
1742b3d528690a Magnus Karlsson 2020-08-28   83  				struct xsk_buff_pool *pool,
0a714186d3c0f7 Björn Töpel     2018-08-28   84  				u16 qid)
0a714186d3c0f7 Björn Töpel     2018-08-28   85  {
f3fef2b6e1cc80 Jan Sokolowski  2018-12-18   86  	struct net_device *netdev = vsi->netdev;
0a714186d3c0f7 Björn Töpel     2018-08-28   87  	bool if_running;
0a714186d3c0f7 Björn Töpel     2018-08-28   88  	int err;
0a714186d3c0f7 Björn Töpel     2018-08-28   89  
0a714186d3c0f7 Björn Töpel     2018-08-28   90  	if (vsi->type != I40E_VSI_MAIN)
0a714186d3c0f7 Björn Töpel     2018-08-28   91  		return -EINVAL;
0a714186d3c0f7 Björn Töpel     2018-08-28   92  
0a714186d3c0f7 Björn Töpel     2018-08-28   93  	if (qid >= vsi->num_queue_pairs)
0a714186d3c0f7 Björn Töpel     2018-08-28   94  		return -EINVAL;
0a714186d3c0f7 Björn Töpel     2018-08-28   95  
f3fef2b6e1cc80 Jan Sokolowski  2018-12-18   96  	if (qid >= netdev->real_num_rx_queues ||
f3fef2b6e1cc80 Jan Sokolowski  2018-12-18   97  	    qid >= netdev->real_num_tx_queues)
0a714186d3c0f7 Björn Töpel     2018-08-28   98  		return -EINVAL;
0a714186d3c0f7 Björn Töpel     2018-08-28   99  
c4655761d3cf62 Magnus Karlsson 2020-08-28  100  	err = xsk_pool_dma_map(pool, &vsi->back->pdev->dev, I40E_RX_DMA_ATTR);
0a714186d3c0f7 Björn Töpel     2018-08-28  101  	if (err)
0a714186d3c0f7 Björn Töpel     2018-08-28  102  		return err;
0a714186d3c0f7 Björn Töpel     2018-08-28  103  
44ddd4f1709249 Björn Töpel     2019-02-12  104  	set_bit(qid, vsi->af_xdp_zc_qps);
44ddd4f1709249 Björn Töpel     2019-02-12  105  

31 more lines

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()

Message details and related content
Hi Haoxiang,

kernel test robot noticed the following build errors:

[auto build test ERROR on tnguy-next-queue/dev-queue]
[also build test ERROR on tnguy-net-queue/dev-queue linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/i40e-add-an-error-handling-path-in-i40e_xsk_pool_enable/20260131-135447
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link:    https://lore.kernel.org/r/20260131055217.729048-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260201/202602010050.pI2ZZmft-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260201/202602010050.pI2ZZmft-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot [off-list ref]
| Closes: https://lore.kernel.org/oe-kbuild-all/202602010050.pI2ZZmft-lkp@intel.com/

All errors (new ones prefixed by >>):
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:2: error: call to undeclared function 'i40e_xsk_pool_disable'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:2: note: did you mean 'i40e_xsk_pool_enable'?
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:82:12: note: 'i40e_xsk_pool_enable' declared here
      82 | static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
         |            ^
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:141:12: error: conflicting types for 'i40e_xsk_pool_disable'
     141 | static int i40e_xsk_pool_disable(struct i40e_vsi *vsi, u16 qid)
         |            ^
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:2: note: previous implicit declaration is here
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^
   2 errors generated.


vim +/i40e_xsk_pool_disable +130 drivers/net/ethernet/intel/i40e/i40e_xsk.c

    72	
    73	/**
    74	 * i40e_xsk_pool_enable - Enable/associate an AF_XDP buffer pool to a
    75	 * certain ring/qid
    76	 * @vsi: Current VSI
    77	 * @pool: buffer pool
    78	 * @qid: Rx ring to associate buffer pool with
    79	 *
    80	 * Returns 0 on success, <0 on failure
    81	 **/
    82	static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
    83					struct xsk_buff_pool *pool,
    84					u16 qid)
    85	{
    86		struct net_device *netdev = vsi->netdev;
    87		bool if_running;
    88		int err;
    89	
    90		if (vsi->type != I40E_VSI_MAIN)
    91			return -EINVAL;
    92	
    93		if (qid >= vsi->num_queue_pairs)
    94			return -EINVAL;
    95	
    96		if (qid >= netdev->real_num_rx_queues ||
    97		    qid >= netdev->real_num_tx_queues)
    98			return -EINVAL;
    99	
   100		err = xsk_pool_dma_map(pool, &vsi->back->pdev->dev, I40E_RX_DMA_ATTR);
   101		if (err)

77 more lines

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()

Message details and related content
Hi Haoxiang,

kernel test robot noticed the following build errors:

[auto build test ERROR on tnguy-next-queue/dev-queue]
[also build test ERROR on tnguy-net-queue/dev-queue linus/master v6.19-rc7 next-20260130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/i40e-add-an-error-handling-path-in-i40e_xsk_pool_enable/20260131-135447
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link:    https://lore.kernel.org/r/20260131055217.729048-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20260201/202602011335.eVX5YSY8-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260201/202602011335.eVX5YSY8-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot [off-list ref]
| Closes: https://lore.kernel.org/oe-kbuild-all/202602011335.eVX5YSY8-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/ethernet/intel/i40e/i40e_xsk.c: In function 'i40e_xsk_pool_enable':
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: error: implicit declaration of function 'i40e_xsk_pool_disable'; did you mean 'i40e_xsk_pool_enable'? [-Wimplicit-function-declaration]
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~
         |         i40e_xsk_pool_enable
   drivers/net/ethernet/intel/i40e/i40e_xsk.c: At top level:
quoted
drivers/net/ethernet/intel/i40e/i40e_xsk.c:141:12: error: conflicting types for 'i40e_xsk_pool_disable'; have 'int(struct i40e_vsi *, u16)' {aka 'int(struct i40e_vsi *, short unsigned int)'}
     141 | static int i40e_xsk_pool_disable(struct i40e_vsi *vsi, u16 qid)
         |            ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:142:1: note: an argument type that has a default promotion cannot match an empty parameter name list declaration
     142 | {
         | ^
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: note: previous implicit declaration of 'i40e_xsk_pool_disable' with type 'int()'
     130 |         i40e_xsk_pool_disable(vsi, qid);
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c: In function 'i40e_xsk_pool_enable':
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
     131 | }
         | ^


vim +130 drivers/net/ethernet/intel/i40e/i40e_xsk.c

    72	
    73	/**
    74	 * i40e_xsk_pool_enable - Enable/associate an AF_XDP buffer pool to a
    75	 * certain ring/qid
    76	 * @vsi: Current VSI
    77	 * @pool: buffer pool
    78	 * @qid: Rx ring to associate buffer pool with
    79	 *
    80	 * Returns 0 on success, <0 on failure
    81	 **/
    82	static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
    83					struct xsk_buff_pool *pool,
    84					u16 qid)
    85	{
    86		struct net_device *netdev = vsi->netdev;
    87		bool if_running;
    88		int err;
    89	
    90		if (vsi->type != I40E_VSI_MAIN)
    91			return -EINVAL;
    92	
    93		if (qid >= vsi->num_queue_pairs)
    94			return -EINVAL;
    95	

83 more lines

Re: [Intel-wired-lan] [PATCH v2] i40e: add an error handling path in i40e_xsk_pool_enable()

Message details and related content
Hi Haoxiang,

The kernel test robot reported the following build error on your v2:

  drivers/net/ethernet/intel/i40e/i40e_xsk.c:130:9: error: implicit declaration of function 'i40e_xsk_pool_disable'; did you mean 'i40e_xsk_pool_enable'?
  drivers/net/ethernet/intel/i40e/i40e_xsk.c:141:12: error: conflicting types for 'i40e_xsk_pool_disable'

The root cause is that i40e_xsk_pool_disable() is defined after i40e_xsk_pool_enable() in i40e_xsk.c [citation:4]. When the error path in i40e_xsk_pool_enable() calls i40e_xsk_pool_disable(), the compiler has not yet seen its prototype.

One way to fix this without reordering functions is to unwind the two operations that i40e_xsk_pool_enable() itself performed in the error path:
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 9f47388eaba5..97d016be493d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -108,23 +108,31 @@ static int i40e_xsk_pool_enable(struct i40e_vsi *vsi,
        if (if_running) {
                err = i40e_queue_pair_disable(vsi, qid);
                if (err)
-                       return err;
+                       goto err_pool_unmap;

                err = i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], true);
                if (err)
-                       return err;
+                       goto err_pool_unmap;

                err = i40e_queue_pair_enable(vsi, qid);
                if (err)
-                       return err;
+                       goto err_realloc;

                /* Kick start the NAPI context so that receiving will start */
                err = i40e_xsk_wakeup(vsi->netdev, qid, XDP_WAKEUP_RX);
                if (err)
-                       return err;
+                       goto err_realloc;
        }

        return 0;
+
+err_realloc:
+       i40e_realloc_rx_xdp_bi(vsi->rx_rings[qid], false);
+err_pool_unmap:
+       clear_bit(qid, vsi->af_xdp_zc_qps);
+       xsk_pool_dma_unmap(pool, I40E_RX_DMA_ATTR);
+
+       return err;
 }
This mirrors the internal logic of i40e_xsk_pool_disable() [citation:12] ��� clear the zero-copy bit and DMA-unmap the pool ��� without calling a function defined later in the file. It also avoids the limbo-state concern you mentioned in your v2 changelog, since it does not go through the pool-association check in i40e_xsk_pool_disable().

Alternatively, a forward declaration of i40e_xsk_pool_disable() at the top of i40e_xsk.c would also resolve the build error.

Best regards,
Linkui Xiao

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help