From b94e29816f492eacb46da81a7dc058ec1d6ad0cc Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 3 Aug 2000 03:39:52 +0000 Subject: [PATCH] MALLOC()/FREE() are not to be used for variable sized allocations. --- sys/isofs/cd9660/cd9660_vnops.c | 7 +++---- sys/miscfs/fdesc/fdesc_vnops.c | 9 +++++---- sys/miscfs/kernfs/kernfs_vnops.c | 7 +++---- sys/miscfs/procfs/procfs_vnops.c | 8 ++++---- sys/ntfs/ntfs_vnops.c | 5 ++--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 33be06849ef7..aa8e76dbe366 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vnops.c,v 1.58 2000/05/27 16:03:56 jdolecek Exp $ */ +/* $NetBSD: cd9660_vnops.c,v 1.59 2000/08/03 03:39:52 thorpej Exp $ */ /*- * Copyright (c) 1994 @@ -469,8 +469,7 @@ cd9660_readdir(v) idp->cookies = NULL; else { ncookies = uio->uio_resid / 16; - MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP, - M_WAITOK); + cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK); idp->cookies = cookies; idp->ncookies = ncookies; } @@ -591,7 +590,7 @@ cd9660_readdir(v) if (ap->a_ncookies != NULL) { if (error) - FREE(cookies, M_TEMP); + free(cookies, M_TEMP); else { /* * Work out the number of cookies actually used. diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c index d5b9ebd28377..bd122053739c 100644 --- a/sys/miscfs/fdesc/fdesc_vnops.c +++ b/sys/miscfs/fdesc/fdesc_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vnops.c,v 1.55 2000/05/27 04:52:39 thorpej Exp $ */ +/* $NetBSD: fdesc_vnops.c,v 1.56 2000/08/03 03:41:17 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -725,7 +725,7 @@ fdesc_readdir(v) if (ap->a_ncookies) { ncookies = min(ncookies, (nfdesc_targets - i)); - MALLOC(cookies, off_t *, ncookies * sizeof(off_t), + cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK); *ap->a_cookies = cookies; *ap->a_ncookies = ncookies; @@ -762,7 +762,8 @@ fdesc_readdir(v) } else { if (ap->a_ncookies) { ncookies = min(ncookies, (fdp->fd_nfiles + 2)); - MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP, M_WAITOK); + cookies = malloc(ncookies * sizeof(off_t), + M_TEMP, M_WAITOK); *ap->a_cookies = cookies; *ap->a_ncookies = ncookies; } @@ -795,7 +796,7 @@ fdesc_readdir(v) } if (ap->a_ncookies && error) { - FREE(*ap->a_cookies, M_TEMP); + free(*ap->a_cookies, M_TEMP); *ap->a_ncookies = 0; *ap->a_cookies = NULL; } diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c index 604213d66075..a2cecee640a0 100644 --- a/sys/miscfs/kernfs/kernfs_vnops.c +++ b/sys/miscfs/kernfs/kernfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.69 2000/07/14 07:21:50 thorpej Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.70 2000/08/03 03:41:18 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -638,8 +638,7 @@ kernfs_readdir(v) if (ap->a_ncookies) { nc = uio->uio_resid / UIO_MX; nc = min(nc, (nkern_targets - i)); - MALLOC(cookies, off_t *, nc * sizeof(off_t), M_TEMP, - M_WAITOK); + cookies = malloc(nc * sizeof(off_t), M_TEMP, M_WAITOK); *ap->a_cookies = cookies; } @@ -672,7 +671,7 @@ kernfs_readdir(v) if (ap->a_ncookies) { if (error) { - FREE(*ap->a_cookies, M_TEMP); + free(*ap->a_cookies, M_TEMP); *ap->a_ncookies = 0; *ap->a_cookies = NULL; } else diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index f1240c29c309..2bf2ba0ad36f 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_vnops.c,v 1.71 2000/06/28 02:44:07 mrg Exp $ */ +/* $NetBSD: procfs_vnops.c,v 1.72 2000/08/03 03:41:18 thorpej Exp $ */ /* * Copyright (c) 1993 Jan-Simon Pendry @@ -894,7 +894,7 @@ procfs_readdir(v) if (ap->a_ncookies) { ncookies = min(ncookies, (nproc_targets - i)); - MALLOC(cookies, off_t *, ncookies * sizeof (off_t), + cookies = malloc(ncookies * sizeof (off_t), M_TEMP, M_WAITOK); *ap->a_cookies = cookies; } @@ -940,7 +940,7 @@ procfs_readdir(v) * XXX Potentially allocating too much space here, * but I'm lazy. This loop needs some work. */ - MALLOC(cookies, off_t *, ncookies * sizeof (off_t), + cookies = malloc(ncookies * sizeof (off_t), M_TEMP, M_WAITOK); *ap->a_cookies = cookies; } @@ -1022,7 +1022,7 @@ procfs_readdir(v) if (ap->a_ncookies) { if (error) { if (cookies) - FREE(*ap->a_cookies, M_TEMP); + free(*ap->a_cookies, M_TEMP); *ap->a_ncookies = 0; *ap->a_cookies = NULL; } else diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index 752aab94250a..dbddf161b776 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_vnops.c,v 1.28 2000/07/30 09:29:28 simonb Exp $ */ +/* $NetBSD: ntfs_vnops.c,v 1.29 2000/08/03 03:41:54 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -686,8 +686,7 @@ ntfs_readdir(ap) MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, M_WAITOK); #else /* defined(__NetBSD__) */ - MALLOC(cookies, off_t *, ncookies * sizeof(off_t), - M_TEMP, M_WAITOK); + cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK); #endif for (dp = dpStart, cookiep = cookies, i=0; i < ncookies;