]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Do not attempt to unmap a null I/O buffer
authorMichael Brown <mcb30@ipxe.org>
Sun, 29 Nov 2020 11:21:20 +0000 (11:21 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sun, 29 Nov 2020 11:25:40 +0000 (11:25 +0000)
netdev_tx_err() may be called with a null I/O buffer (e.g. to record a
transmit error with no associated buffer).  Avoid a potential null
pointer dereference in the DMA unmapping code path.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/netdevice.c

index f3feca26bfed7956788b811f3b104dff524e73a3..754799cd1da37f13fc4a15b863690b435332629f 100644 (file)
@@ -392,7 +392,7 @@ void netdev_tx_err ( struct net_device *netdev,
        }
 
        /* Unmap I/O buffer, if required */
-       if ( dma_mapped ( &iobuf->map ) )
+       if ( iobuf && dma_mapped ( &iobuf->map ) )
                iob_unmap ( iobuf );
 
        /* Discard packet */