Skip to content

Commit 0e5b09b

Browse files
Dan Carpenterandy-shev
authored andcommitted
platform/x86: dell-smbios: Fix memory leaks in build_tokens_sysfs()
We're freeing "value_name" which is NULL, so that's a no-op, but we intended to free "location_name" instead. And then we don't free the names in token_location_attrs[0] and token_value_attrs[0]. Fixes: 33b9ca1 ("platform/x86: dell-smbios: Add a sysfs interface for SMBIOS tokens") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 2b5de0c commit 0e5b09b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/platform/x86/dell-smbios-base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static int build_tokens_sysfs(struct platform_device *dev)
514514
continue;
515515

516516
loop_fail_create_value:
517-
kfree(value_name);
517+
kfree(location_name);
518518
goto out_unwind_strings;
519519
}
520520
smbios_attribute_group.attrs = token_attrs;
@@ -525,7 +525,7 @@ static int build_tokens_sysfs(struct platform_device *dev)
525525
return 0;
526526

527527
out_unwind_strings:
528-
for (i = i-1; i > 0; i--) {
528+
while (i--) {
529529
kfree(token_location_attrs[i].attr.name);
530530
kfree(token_value_attrs[i].attr.name);
531531
}

0 commit comments

Comments
 (0)