From: Armin Wolf <W_Armin@gmx.de>
To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] platform/x86: dell-smbios: Simplify error handling
Date: Tue, 28 May 2024 22:49:03 +0200 [thread overview]
Message-ID: <20240528204903.445546-2-W_Armin@gmx.de> (raw)
In-Reply-To: <20240528204903.445546-1-W_Armin@gmx.de>
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 <W_Armin@gmx.de>
---
Changes since v1:
- add patch
---
drivers/platform/x86/dell/dell-smbios-base.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-smbios-base.c b/drivers/platform/x86/dell/dell-smbios-base.c
index 86b95206cb1b..b562ed99ec4e 100644
--- a/drivers/platform/x86/dell/dell-smbios-base.c
+++ b/drivers/platform/x86/dell/dell-smbios-base.c
@@ -492,19 +492,16 @@ static int build_tokens_sysfs(struct platform_device *dev)
/* add value */
value_name = kasprintf(GFP_KERNEL, "%04x_value",
da_tokens[i].tokenID);
- if (value_name == NULL)
- goto loop_fail_create_value;
+ if (!value_name) {
+ kfree(location_name);
+ goto out_unwind_strings;
+ }
sysfs_attr_init(&token_entries[i].value_attr.attr);
token_entries[i].value_attr.attr.name = value_name;
token_entries[i].value_attr.attr.mode = 0444;
token_entries[i].value_attr.show = value_show;
token_attrs[j++] = &token_entries[i].value_attr.attr;
- continue;
-
-loop_fail_create_value:
- kfree(location_name);
- goto out_unwind_strings;
}
smbios_attribute_group.attrs = token_attrs;
--
2.39.2
next prev parent reply other threads:[~2024-05-28 20:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 20:49 [PATCH v2 1/2] platform/x86: dell-smbios: Fix wrong token data in sysfs Armin Wolf
2024-05-28 20:49 ` Armin Wolf [this message]
2024-05-31 16:19 ` [PATCH v2 2/2] platform/x86: dell-smbios: Simplify error handling Ilpo Järvinen
2024-05-31 16:17 ` [PATCH v2 1/2] platform/x86: dell-smbios: Fix wrong token data in sysfs Ilpo Järvinen
2024-06-03 9:56 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240528204903.445546-2-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®