From 75548271a9c90fbe4f89d2e42d4d7e5e561028eb Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 7 Jun 2016 20:33:55 +0000 Subject: [PATCH] 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 --- sys/cam/ata/ata_da.c | 1 + sys/cam/scsi/scsi_da.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 2e7550026141..72ced86f05e1 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1672,6 +1672,7 @@ adaregister(struct cam_periph *periph, void *arg) 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); } diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index aa05b703c81b..deef952cdde9 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2377,6 +2377,7 @@ daregister(struct cam_periph *periph, void *arg) 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); }