svn commit: r363205 - head/sys/compat/linuxkpi/common/include/linux

Vladimir Kondratyev wulf at FreeBSD.org
Tue Jul 14 21:57:02 UTC 2020


Author: wulf
Date: Tue Jul 14 21:56:59 2020
New Revision: 363205
URL: https://svnweb.freebsd.org/changeset/base/363205

Log:
  linuxkpi: Ignore NULL pointers passed to string parameter of kstr(n)dup
  
  That follows Linux and fixes related drm-kmod-5.3 panic.
  
  Reviewed by:	imp, hselasky
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D25657

Modified:
  head/sys/compat/linuxkpi/common/include/linux/string.h

Modified: head/sys/compat/linuxkpi/common/include/linux/string.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/string.h	Tue Jul 14 21:43:57 2020	(r363204)
+++ head/sys/compat/linuxkpi/common/include/linux/string.h	Tue Jul 14 21:56:59 2020	(r363205)
@@ -103,6 +103,8 @@ kstrdup(const char *string, gfp_t gfp)
 	char *retval;
 	size_t len;
 
+	if (string == NULL)
+		return (NULL);
 	len = strlen(string) + 1;
 	retval = kmalloc(len, gfp);
 	if (retval != NULL)
@@ -115,6 +117,8 @@ kstrndup(const char *string, size_t len, gfp_t gfp)
 {
 	char *retval;
 
+	if (string == NULL)
+		return (NULL);
 	retval = kmalloc(len + 1, gfp);
 	if (retval != NULL)
 		strncpy(retval, string, len);


More information about the svn-src-head mailing list