Commit f921fb13 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Greg Kroah-Hartman

greybus: power_supply: fix leak getting string properties

When fetching string properties, memory was being allocated and leaked
when it was not necessary to do so.
Signed-off-by: default avatarRui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent d9eafd58
...@@ -347,15 +347,13 @@ static int __gb_power_supply_property_strval_get(struct gb_power_supply *gbpsy, ...@@ -347,15 +347,13 @@ static int __gb_power_supply_property_strval_get(struct gb_power_supply *gbpsy,
{ {
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_MODEL_NAME: case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = kstrndup(gbpsy->model_name, PROP_MAX, GFP_KERNEL); val->strval = gbpsy->model_name;
break; break;
case POWER_SUPPLY_PROP_MANUFACTURER: case POWER_SUPPLY_PROP_MANUFACTURER:
val->strval = kstrndup(gbpsy->manufacturer, PROP_MAX, val->strval = gbpsy->manufacturer;
GFP_KERNEL);
break; break;
case POWER_SUPPLY_PROP_SERIAL_NUMBER: case POWER_SUPPLY_PROP_SERIAL_NUMBER:
val->strval = kstrndup(gbpsy->serial_number, PROP_MAX, val->strval = gbpsy->serial_number;
GFP_KERNEL);
break; break;
default: default:
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment