david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[slam] Fix resource leak on error path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2017-03-21 14:53:13 +02:00
parent 8963193cda
commit 60561d0f3d
1 changed files with 10 additions and 4 deletions

View 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;
}
/**