aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2022-06-06 08:23:23 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2022-06-06 08:31:34 +0000
commit85d7875d42913c2cb10a007a1be05b210dc6aab2 (patch)
tree4d7ecc4e431314f6b337d528b14126292c0fdd54
parentcd7e11f78dedad810273ae71d791027e75aa16c9 (diff)
LinuxKPI: Fix dmi_matches() function
Make sure to check for NULL pointers and also check all search criterias, not only the first one! Bump the FreeBSD version. Reviewed by: manu@ Differential Revision: https://reviews.freebsd.org/D35403 MFC after: 1 week Sponsored by: NVIDIA Networking
-rw-r--r--sys/compat/linuxkpi/common/src/linux_dmi.c19
-rw-r--r--sys/sys/param.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_dmi.c b/sys/compat/linuxkpi/common/src/linux_dmi.c
index f5350751a496..70d56c246c10 100644
--- a/sys/compat/linuxkpi/common/src/linux_dmi.c
+++ b/sys/compat/linuxkpi/common/src/linux_dmi.c
@@ -77,20 +77,25 @@ linux_dmi_match(enum dmi_field f, const char *str)
static bool
linux_dmi_matches(const struct dmi_system_id *dsi)
{
+ enum dmi_field slot;
int i;
for (i = 0; i < nitems(dsi->matches); i++) {
- if (dsi->matches[i].slot == DMI_NONE)
+ slot = dsi->matches[i].slot;
+ if (slot == DMI_NONE)
break;
+ if (slot >= DMI_STRING_MAX ||
+ dmi_data[slot] == NULL)
+ return (false);
if (dsi->matches[i].exact_match) {
- return (dmi_match(dsi->matches[i].slot,
- dsi->matches[i].substr));
- } else {
- return (strstr(dmi_data[dsi->matches[i].slot],
- dsi->matches[i].substr) != NULL);
+ if (dmi_match(slot, dsi->matches[i].substr))
+ continue;
+ } else if (strstr(dmi_data[slot],
+ dsi->matches[i].substr) != NULL) {
+ continue;
}
+ return (false);
}
-
return (true);
}
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 1f720ed31142..d68b5c2d4f2f 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -76,7 +76,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1400059
+#define __FreeBSD_version 1400060
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,