Date: Fri, 7 Aug 2020 19:58:16 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364043 - head/sys/cam/mmc Message-ID: <202008071958.077JwG9L069030@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008071958.077JwG9L069030>