Skip to content

Commit

Permalink
[slam] Fix resource leak on error path
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 21, 2017
1 parent 8963193 commit 60561d0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/net/udp/slam.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 60561d0

Please sign in to comment.