Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2020 23:36:18 +0000 (UTC)
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r363406 - stable/12/sys/compat/linuxkpi/common/include/linux
Message-ID:  <202007212336.06LNaISG062925@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wulf
Date: Tue Jul 21 23:36:18 2020
New Revision: 363406
URL: https://svnweb.freebsd.org/changeset/base/363406

Log:
  MFC r363205:
  
  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
  Differential Revision:	https://reviews.freebsd.org/D25657

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/string.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/string.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/string.h	Tue Jul 21 23:23:08 2020	(r363405)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/string.h	Tue Jul 21 23:36:18 2020	(r363406)
@@ -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);



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