⬢ DragonFlyBSD Kernel Audit
DF-2216 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/linux_dmi.c
+++ b/sys/dev/drm/linux_dmi.c
@@ -35,30 +35,50 @@
 bool
 dmi_match(enum dmi_field f, const char *str)
 {
-	const char *s = NULL;
+	char *s = NULL;
 
 	switch (f) {
 	case DMI_NONE:
 		break;
 	case DMI_SYS_VENDOR:
 		s = kgetenv("smbios.system.maker");
-		if (s != NULL && !strcmp(s, str))
-			return true;
+		if (s != NULL) {
+			if (!strcmp(s, str)) {
+				kfreeenv(s);
+				return true;
+			}
+			kfreeenv(s);
+		}
 		break;
 	case DMI_BOARD_VENDOR:
 		s = kgetenv("smbios.planar.maker");
-		if (s != NULL && !strcmp(s, str))
-			return true;
+		if (s != NULL) {
+			if (!strcmp(s, str)) {
+				kfreeenv(s);
+				return true;
+			}
+			kfreeenv(s);
+		}
 		break;
 	case DMI_PRODUCT_NAME:
 		s = kgetenv("smbios.system.product");
-		if (s != NULL && !strcmp(s, str))
-			return true;
+		if (s != NULL) {
+			if (!strcmp(s, str)) {
+				kfreeenv(s);
+				return true;
+			}
+			kfreeenv(s);
+		}
 		break;
 	case DMI_BOARD_NAME:
 		s = kgetenv("smbios.planar.product");
-		if (s != NULL && !strcmp(s, str))
-			return true;
+		if (s != NULL) {
+			if (!strcmp(s, str)) {
+				kfreeenv(s);
+				return true;
+			}
+			kfreeenv(s);
+		}
 		break;
 	default:
 		return false;