Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 May 2020 13:00:39 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r360845 - head/sys/kern
Message-ID:  <202005091300.049D0dxb037457@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat May  9 13:00:38 2020
New Revision: 360845
URL: https://svnweb.freebsd.org/changeset/base/360845

Log:
  Avoid spurious ENOMEMs from sysctl hw.pagesizes.
  
  Reported by:	Paul Floyd <paulf@free.fr>
  PR:	246215
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D24737

Modified:
  head/sys/kern/kern_mib.c

Modified: head/sys/kern/kern_mib.c
==============================================================================
--- head/sys/kern/kern_mib.c	Sat May  9 12:58:27 2020	(r360844)
+++ head/sys/kern/kern_mib.c	Sat May  9 13:00:38 2020	(r360845)
@@ -231,6 +231,7 @@ static int
 sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
 {
 	int error;
+	size_t len;
 #ifdef SCTL_MASK32
 	int i;
 	uint32_t pagesizes32[MAXPAGESIZES];
@@ -243,10 +244,18 @@ sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
 		for (i = 0; i < MAXPAGESIZES; i++)
 			pagesizes32[i] = (uint32_t)pagesizes[i];
 
-		error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32));
+		len = sizeof(pagesizes32);
+		if (len > req->oldlen)
+			len = req->oldlen;
+		error = SYSCTL_OUT(req, pagesizes32, len);
 	} else
 #endif
-		error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes));
+	{
+		len = sizeof(pagesizes);
+		if (len > req->oldlen)
+			len = req->oldlen;
+		error = SYSCTL_OUT(req, pagesizes, len);
+	}
 	return (error);
 }
 SYSCTL_PROC(_hw, OID_AUTO, pagesizes,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005091300.049D0dxb037457>