aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Kondratyev <wulf@FreeBSD.org>2020-07-14 21:56:59 +0000
committerVladimir Kondratyev <wulf@FreeBSD.org>2020-07-14 21:56:59 +0000
commit34c2f79d835569e758b3d448e672a2ca81541f0a (patch)
tree4c167486b9d63c2c3b5fe8baa49bf6eac487ad16
parent29f3e5ea41f2366598179210ae9521823e6a05a0 (diff)
downloadsrc-34c2f79d835569e758b3d448e672a2ca81541f0a.tar.gz
src-34c2f79d835569e758b3d448e672a2ca81541f0a.zip
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
Notes
Notes: svn path=/head/; revision=363205
-rw-r--r--sys/compat/linuxkpi/common/include/linux/string.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index d8d509778adb..39201e203162 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -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);