Author: cem
Date: Tue Jun  7 20:33:55 2016
New Revision: 301568
URL: https://svnweb.freebsd.org/changeset/base/301568

Log:
  Fix memory leaks in (a|)daregister introduced in r298002
  
  In the case where cam_iosched_init() fails, the ada and da softcs were leaked.
  Instead, free them.
  
  Reported by:  Coverity
  CID:          1356039
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c   Tue Jun  7 20:26:00 2016        (r301567)
+++ head/sys/cam/ata/ata_da.c   Tue Jun  7 20:33:55 2016        (r301568)
@@ -1672,6 +1672,7 @@ adaregister(struct cam_periph *periph, v
        if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
                printf("adaregister: Unable to probe new device. "
                       "Unable to allocate iosched memory\n");
+               free(softc, M_DEVBUF);
                return(CAM_REQ_CMP_ERR);
        }
 

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c Tue Jun  7 20:26:00 2016        (r301567)
+++ head/sys/cam/scsi/scsi_da.c Tue Jun  7 20:33:55 2016        (r301568)
@@ -2377,6 +2377,7 @@ daregister(struct cam_periph *periph, vo
        if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
                printf("daregister: Unable to probe new device. "
                       "Unable to allocate iosched memory\n");
+               free(softc, M_DEVBUF);
                return(CAM_REQ_CMP_ERR);
        }
        
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to