Re: [PATCH] platform/x86: hp-bioscfg: Use more common code in hp_init_bios_package_attribute()

From: Ilpo Järvinen

Date: Wed Jul 01 2026 - 07:53:51 EST


On Thu, 18 Jun 2026, Markus Elfring wrote:

> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Thu, 18 Jun 2026 21:42:27 +0200
>
> Use an existing label once more so that a bit of common code can be better
> reused at the end of this function implementation.
>
> This issue was detected by using the Coccinelle software.

This patch leaves me quite unimpressed of Coccinelle's abilities.

> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> index 27fd6cd21529..819313a4425a 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> @@ -692,8 +692,7 @@ static int hp_init_bios_package_attribute(enum hp_wmi_data_type attr_type,
> if (ret) {
> pr_debug("Failed to populate integer package data. Error [0%0x]\n",
> ret);
> - kfree(str_value);
> - return ret;
> + goto pack_attr_exit;

If a call fails, it's expected to handle cleanup itself --- which is
exactly what hp_convert_hexstr_to_str() appears to be doing (by not
writing into *str until it's committed to returning 0). So why is
this kfree() necessary in the first place?!?

--
i.