From 8798577080aa6560b73a895ff3c0a0e9d8123f8e Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 6 Apr 2017 03:15:29 +0000 Subject: [PATCH] add sizes to free() calls ok dhill --- sys/dev/sdmmc/sdhc.c | 4 ++-- sys/dev/sdmmc/sdmmc.c | 8 ++++---- sys/dev/sdmmc/sdmmc_mem.c | 4 ++-- sys/dev/sdmmc/sdmmc_scsi.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c index b2ed0f23afc..ca8fbaa4bc4 100644 --- a/sys/dev/sdmmc/sdhc.c +++ b/sys/dev/sdmmc/sdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc.c,v 1.53 2017/01/21 05:42:04 guenther Exp $ */ +/* $OpenBSD: sdhc.c,v 1.54 2017/04/06 03:15:29 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -326,7 +326,7 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t iot, return 0; err: - free(hp, M_DEVBUF, 0); + free(hp, M_DEVBUF, sizeof *hp); sc->sc_host[sc->sc_nhosts - 1] = NULL; sc->sc_nhosts--; return (error); diff --git a/sys/dev/sdmmc/sdmmc.c b/sys/dev/sdmmc/sdmmc.c index c176c8b6100..8f20fd0546f 100644 --- a/sys/dev/sdmmc/sdmmc.c +++ b/sys/dev/sdmmc/sdmmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdmmc.c,v 1.45 2017/01/21 05:42:04 guenther Exp $ */ +/* $OpenBSD: sdmmc.c,v 1.46 2017/04/06 03:15:29 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -476,7 +476,7 @@ sdmmc_set_bus_power(struct sdmmc_softc *sc, u_int32_t host_ocr, /* Mask off unsupported voltage levels and select the lowest. */ DPRINTF(1,("%s: host_ocr=%x ", DEVNAME(sc), host_ocr)); host_ocr &= card_ocr; - for (bit = 4; bit < 23; bit++) { +b for (bit = 4; bit < 23; bit++) { if (ISSET(host_ocr, 1<c_data) - free(data, M_TEMP, 0); + free(data, M_TEMP, ucmd->c_datalen); break; default: diff --git a/sys/dev/sdmmc/sdmmc_mem.c b/sys/dev/sdmmc/sdmmc_mem.c index bef4eb614ff..4d926ff0f63 100644 --- a/sys/dev/sdmmc/sdmmc_mem.c +++ b/sys/dev/sdmmc/sdmmc_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdmmc_mem.c,v 1.29 2016/05/05 20:40:48 kettenis Exp $ */ +/* $OpenBSD: sdmmc_mem.c,v 1.30 2017/04/06 03:15:29 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -442,7 +442,7 @@ sdmmc_mem_send_cxd_data(struct sdmmc_softc *sc, int opcode, void *data, out: if (ptr != NULL) - free(ptr, M_DEVBUF, 0); + free(ptr, M_DEVBUF, datalen); return error; } diff --git a/sys/dev/sdmmc/sdmmc_scsi.c b/sys/dev/sdmmc/sdmmc_scsi.c index 2bd6388246a..0e4c98fb2c8 100644 --- a/sys/dev/sdmmc/sdmmc_scsi.c +++ b/sys/dev/sdmmc/sdmmc_scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdmmc_scsi.c,v 1.38 2017/01/21 05:42:04 guenther Exp $ */ +/* $OpenBSD: sdmmc_scsi.c,v 1.39 2017/04/06 03:15:29 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -152,7 +152,7 @@ sdmmc_scsi_attach(struct sdmmc_softc *sc) sdmmc_free_ccbs(scbus); free_sctgt: free(scbus->sc_tgt, M_DEVBUF, 0); - free(scbus, M_DEVBUF, 0); + free(scbus, M_DEVBUF, sizeof *scbus); } void @@ -182,7 +182,7 @@ sdmmc_scsi_detach(struct sdmmc_softc *sc) free(scbus->sc_tgt, M_DEVBUF, 0); sdmmc_free_ccbs(scbus); - free(scbus, M_DEVBUF, 0); + free(scbus, M_DEVBUF, sizeof *scbus); sc->sc_scsibus = NULL; } -- 2.20.1