[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230725220056.25560-4-jorge.lopez2@hp.com>
Date: Tue, 25 Jul 2023 17:00:54 -0500
From: Jorge Lopez <jorgealtxwork@...il.com>
To: hdegoede@...hat.com, platform-driver-x86@...r.kernel.org,
linux-kernel@...r.kernel.org, thomas@...ch.de,
ilpo.jarvinen@...ux.intel.com
Subject: [PATCH 3/5] hp-bioscfg: Fix memory leaks in integer_elements_from_package
Address memory leaks in hp_populate_integer_elements_from_package()
and uninitialized variable errors.
Signed-off-by: Jorge Lopez <jorge.lopez2@...com>
---
Based on the latest platform-drivers-x86.git/for-next
---
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
index 7364c5ef9ef8..97f88e0ef0cc 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
@@ -143,7 +143,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
char *str_value = NULL;
int value_len;
int ret;
- u32 int_value;
+ u32 int_value = 0;
int elem;
int reqs;
int eloc;
@@ -179,6 +179,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
if (expected_integer_types[eloc] != integer_obj[elem].type) {
pr_err("Error expected type %d for elem %d, but got type %d instead\n",
expected_integer_types[eloc], elem, integer_obj[elem].type);
+ kfree(str_value);
return -EIO;
}
/* Assign appropriate element value to corresponding field*/
@@ -239,6 +240,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
str_value,
sizeof(integer_data->common.prerequisites[reqs]));
kfree(str_value);
+ str_value = NULL;
}
break;
@@ -258,6 +260,9 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
pr_warn("Invalid element: %d found in Integer attribute or data may be malformed\n", elem);
break;
}
+
+ kfree(str_value);
+ str_value = NULL;
}
exit_integer_package:
kfree(str_value);
--
2.34.1
Powered by blists - more mailing lists