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
This commit is contained in:
parent
1ff80a3400
commit
1e5d733503
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364043
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user