]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[slam] Fix resource leak on error path
authorMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:53:13 +0000 (14:53 +0200)
committerMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:53:13 +0000 (14:53 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/udp/slam.c

index 8fcc97632b050c7e3f561956e431a6c68fa0c1eb..61dd7d985dab17402d7248ea5920a4c621ae5774 100644 (file)
@@ -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;
 }
 
 /**