]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[fcp] Fix potential memory leaks on error paths
authorMichael Brown <mcb30@ipxe.org>
Wed, 3 Nov 2010 01:48:38 +0000 (01:48 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 3 Nov 2010 01:48:59 +0000 (01:48 +0000)
Functions that instantiate objects generally own one reference to the
object being created.  The error paths must therefore usually call
ref_put() to release this reference.

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

index 60a14cf5b59a5811bfb1d3c7de74aca583d2154b..ddb6ccc858054aa63c953f55d0346c204438431d 100644 (file)
@@ -794,6 +794,7 @@ static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
 
  err_xchg_originate:
        fcpcmd_close ( fcpcmd, rc );
+       ref_put ( &fcpcmd->refcnt );
  err_zalloc:
  err_target:
  err_link:
@@ -979,6 +980,7 @@ static int fcpdev_open ( struct interface *parent, struct fc_name *wwn,
 
  err_scsi_open:
        fcpdev_close ( fcpdev, rc );
+       ref_put ( &fcpdev->refcnt );
  err_zalloc:
        fc_ulp_put ( ulp );
  err_ulp_get: