git: 85d7875d4291 - main - LinuxKPI: Fix dmi_matches() function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Jun 2022 08:32:14 UTC
The branch main has been updated by hselasky:
URL: https://cgit.FreeBSD.org/src/commit/?id=85d7875d42913c2cb10a007a1be05b210dc6aab2
commit 85d7875d42913c2cb10a007a1be05b210dc6aab2
Author: Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-06-06 08:23:23 +0000
Commit: Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-06 08:31:34 +0000
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
---
sys/compat/linuxkpi/common/src/linux_dmi.c | 19 ++++++++++++-------
sys/sys/param.h | 2 +-
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,