svn commit: r301568 - in head/sys/cam: ata scsi

Conrad E. Meyer cem at FreeBSD.org
Tue Jun 7 20:33:56 UTC 2016


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);
 	}
 	


More information about the svn-src-all mailing list