Author: rlibby
Date: Tue Jan 14 02:14:02 2020
New Revision: 356716
URL: https://svnweb.freebsd.org/changeset/base/356716

Log:
  malloc: remove assumptions about MINALLOCSIZE
  
  Remove assumptions about the minimum MINALLOCSIZE, in order to allow
  testing of smaller MINALLOCSIZE.  A following patch will lower the
  MINALLOCSIZE, but not so much that the present patch is required for
  correctness at these sites.
  
  Reviewed by:  jeff, markj
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/kern_prot.c
  head/sys/kern/subr_bus.c

Modified: head/sys/kern/kern_prot.c
==============================================================================
--- head/sys/kern/kern_prot.c   Tue Jan 14 02:13:46 2020        (r356715)
+++ head/sys/kern/kern_prot.c   Tue Jan 14 02:14:02 2020        (r356716)
@@ -2054,7 +2054,7 @@ crextend(struct ucred *cr, int n)
         */
        if ( n < PAGE_SIZE / sizeof(gid_t) ) {
                if (cr->cr_agroups == 0)
-                       cnt = MINALLOCSIZE / sizeof(gid_t);
+                       cnt = MAX(1, MINALLOCSIZE / sizeof(gid_t));
                else
                        cnt = cr->cr_agroups * 2;
 

Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c    Tue Jan 14 02:13:46 2020        (r356715)
+++ head/sys/kern/subr_bus.c    Tue Jan 14 02:14:02 2020        (r356716)
@@ -1686,7 +1686,8 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *
                int newsize;
 
                oldlist = dc->devices;
-               newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t));
+               newsize = roundup((unit + 1),
+                   MAX(1, MINALLOCSIZE / sizeof(device_t)));
                newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT);
                if (!newlist)
                        return (ENOMEM);
_______________________________________________
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"

Reply via email to