Skip to content

Commit 306aec7

Browse files
Wer-Wolfjwrdegoede
authored andcommitted
platform/x86: dell-smbios: Simplify error handling
When the allocation of value_name fails, the error handling code uses two gotos for error handling, which is not necessary. Simplify the error handling in this case by only using a single goto. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 1981b29 commit 306aec7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,19 +492,16 @@ static int build_tokens_sysfs(struct platform_device *dev)
492492
/* add value */
493493
value_name = kasprintf(GFP_KERNEL, "%04x_value",
494494
da_tokens[i].tokenID);
495-
if (value_name == NULL)
496-
goto loop_fail_create_value;
495+
if (!value_name) {
496+
kfree(location_name);
497+
goto out_unwind_strings;
498+
}
497499

498500
sysfs_attr_init(&token_entries[i].value_attr.attr);
499501
token_entries[i].value_attr.attr.name = value_name;
500502
token_entries[i].value_attr.attr.mode = 0444;
501503
token_entries[i].value_attr.show = value_show;
502504
token_attrs[j++] = &token_entries[i].value_attr.attr;
503-
continue;
504-
505-
loop_fail_create_value:
506-
kfree(location_name);
507-
goto out_unwind_strings;
508505
}
509506
smbios_attribute_group.attrs = token_attrs;
510507

0 commit comments

Comments
 (0)