diff options
author | Michael Brown <mcb30@ipxe.org> | 2017-03-21 14:53:13 +0200 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2017-03-21 14:53:13 +0200 |
commit | 60561d0f3d3353b11c9b876ef8e098cf696969c3 (patch) | |
tree | 22d0c421b5f8fa46ba3af4f0fac246d1b8b46ca0 /src/net | |
parent | 8963193cda877e087308d85c70486dee29dc8860 (diff) | |
download | ipxe-60561d0f3d3353b11c9b876ef8e098cf696969c3.tar.gz |
[slam] Fix resource leak on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/udp/slam.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/net/udp/slam.c b/src/net/udp/slam.c index 8fcc97632..61dd7d985 100644 --- a/src/net/udp/slam.c +++ b/src/net/udp/slam.c @@ -266,7 +266,8 @@ static int slam_tx_nack ( struct slam_request *slam ) { if ( ! iobuf ) { DBGC ( slam, "SLAM %p could not allocate I/O buffer\n", slam ); - return -ENOMEM; + rc = -ENOMEM; + goto err_alloc; } /* Construct NACK. We always request only a single packet; @@ -294,14 +295,19 @@ static int slam_tx_nack ( struct slam_request *slam ) { "0-%ld\n", slam, ( num_blocks - 1 ) ); } if ( ( rc = slam_put_value ( slam, iobuf, first_block ) ) != 0 ) - return rc; + goto err_put_value; if ( ( rc = slam_put_value ( slam, iobuf, num_blocks ) ) != 0 ) - return rc; + goto err_put_value; nul = iob_put ( iobuf, 1 ); *nul = 0; /* Transmit packet */ - return xfer_deliver_iob ( &slam->socket, iobuf ); + return xfer_deliver_iob ( &slam->socket, iob_disown ( iobuf ) ); + + err_put_value: + free_iob ( iobuf ); + err_alloc: + return rc; } /** |