Author: bz Date: Fri Aug 7 19:58:16 2020 New Revision: 364043 URL: https://svnweb.freebsd.org/changeset/base/364043
Log: mmc_da: fix memory leak in sddaregister() In case we are failing to allocate mmcdata, we are returning with a softc allocated but not attached to anything and thus leak the memory. Reviewed by: scottl MFC after: 2 weeks X-MFC: only if we also mfc other mmccam changes? Differential Revision: https://reviews.freebsd.org/D25987 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Fri Aug 7 19:36:08 2020 (r364042) +++ head/sys/cam/mmc/mmc_da.c Fri Aug 7 19:58:16 2020 (r364043) @@ -789,7 +789,6 @@ sddaregister(struct cam_periph *periph, void *arg) softc = (struct sdda_softc *)malloc(sizeof(*softc), M_DEVBUF, M_NOWAIT|M_ZERO); - if (softc == NULL) { printf("sddaregister: Unable to probe new device. " "Unable to allocate softc\n"); @@ -802,6 +801,7 @@ sddaregister(struct cam_periph *periph, void *arg) if (softc->mmcdata == NULL) { printf("sddaregister: Unable to probe new device. " "Unable to allocate mmcdata\n"); + free(softc, M_DEVBUF); return (CAM_REQ_CMP_ERR); } periph->softc = softc; _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"