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
This commit is contained in:
Hans Petter Selasky 2022-06-06 10:23:23 +02:00
parent cd7e11f78d
commit 85d7875d42
2 changed files with 13 additions and 8 deletions

View File

@ -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);
}

View File

@ -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,