eth: fbnic: avoid double free when failing to DMA-map FW msg
authorJakub Kicinski <kuba@kernel.org>
Mon, 16 Jun 2025 19:55:10 +0000 (12:55 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 19 Jun 2025 10:16:11 +0000 (12:16 +0200)
The semantics are that caller of fbnic_mbx_map_msg() retains
the ownership of the message on error. All existing callers
dutifully free the page.

Fixes: da3cde08209e ("eth: fbnic: Add FW communication mechanism")
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20250616195510.225819-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/meta/fbnic/fbnic_fw.c

index e2368075ab8c60171b5b3f3d08d178005b59dc7d..4521d0483d186a12ccaf02b1ecbff6076da0d430 100644 (file)
@@ -127,11 +127,8 @@ static int fbnic_mbx_map_msg(struct fbnic_dev *fbd, int mbx_idx,
                return -EBUSY;
 
        addr = dma_map_single(fbd->dev, msg, PAGE_SIZE, direction);
-       if (dma_mapping_error(fbd->dev, addr)) {
-               free_page((unsigned long)msg);
-
+       if (dma_mapping_error(fbd->dev, addr))
                return -ENOSPC;
-       }
 
        mbx->buf_info[tail].msg = msg;
        mbx->buf_info[tail].addr = addr;