mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-20 04:19:41 +00:00
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: Rui Miguel Silva <rui.silva@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
d9eafd58e3
commit
f921fb139b
@ -347,15 +347,13 @@ static int __gb_power_supply_property_strval_get(struct gb_power_supply *gbpsy,
|
||||
{
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_MODEL_NAME:
|
||||
val->strval = kstrndup(gbpsy->model_name, PROP_MAX, GFP_KERNEL);
|
||||
val->strval = gbpsy->model_name;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_MANUFACTURER:
|
||||
val->strval = kstrndup(gbpsy->manufacturer, PROP_MAX,
|
||||
GFP_KERNEL);
|
||||
val->strval = gbpsy->manufacturer;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_SERIAL_NUMBER:
|
||||
val->strval = kstrndup(gbpsy->serial_number, PROP_MAX,
|
||||
GFP_KERNEL);
|
||||
val->strval = gbpsy->serial_number;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user