X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] platform/x86: dell-smbios: Simplify error handling
Date: Fri, 31 May 2024 19:19:12 +0300 (EEST)	[thread overview]
Message-ID: <8353e3d0-7553-50f9-160b-fa8b6df2f067@linux.intel.com> (raw)
In-Reply-To: <20240528204903.445546-2-W_Armin@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 1742 bytes --]

On Tue, 28 May 2024, Armin Wolf wrote:

> 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;

Good cleanup. Using continue on the main level of a loop is almost never a 
good idea.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

  reply	other threads:[~2024-05-31 16:19 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 ` [PATCH v2 2/2] platform/x86: dell-smbios: Simplify error handling Armin Wolf
2024-05-31 16:19   ` Ilpo Järvinen [this message]
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=8353e3d0-7553-50f9-160b-fa8b6df2f067@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=W_Armin@gmx.de \
    --cc=hdegoede@redhat.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