diff mbox series

[1/3] platform/x86: hp-bioscfg: fix a signedness bug in hp_wmi_perform_query()

Message ID ad0a6ad9-099b-40a4-ae91-b9dca622ff4e@moroto.mountain (mailing list archive)
State Accepted, archived
Headers show
Series [1/3] platform/x86: hp-bioscfg: fix a signedness bug in hp_wmi_perform_query() | expand

Commit Message

Dan Carpenter July 18, 2023, 7:05 a.m. UTC
The error handling won't work if "mid" is unsigned.  "ret" is used to
store negative error codes and declaring it as a u32 won't cause a bug
but it's ugly.  The "actual_outsize" variable is a number between 0-4096
so it can be declared as int as well.

Fixes: 69ea03e38f24 ("platform/x86: hp-bioscfg: biosattr-interface")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lopez, Jorge A (Security) July 25, 2023, 7:41 p.m. UTC | #1
Reviewed-by: Jorge Lopez <jorge.lopez2@hp.com>


Regards,

Jorge Lopez
HP Inc

"Once you stop learning, you start dying"
Albert Einstein

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Tuesday, July 18, 2023 2:05 AM
> To: Lopez, Jorge A (Security) <jorge.lopez2@hp.com>
> Cc: Hans de Goede <hdegoede@redhat.com>; Mark Gross
> <markgross@kernel.org>; Thomas Weißschuh <linux@weissschuh.net>;
> platform-driver-x86@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: [PATCH 1/3] platform/x86: hp-bioscfg: fix a signedness bug in
> hp_wmi_perform_query()
> 
> CAUTION: External Email
> 
> The error handling won't work if "mid" is unsigned.  "ret" is used to store
> negative error codes and declaring it as a u32 won't cause a bug but it's
> ugly.  The "actual_outsize" variable is a number between 0-4096 so it can be
> declared as int as well.
> 
> Fixes: 69ea03e38f24 ("platform/x86: hp-bioscfg: biosattr-interface")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> index 1d59ad600b84..dea54f35b8b5 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> @@ -123,7 +123,7 @@ int hp_wmi_perform_query(int query, enum
> hp_wmi_command command, void *buffer,
>         struct bios_return *bios_return;
>         union acpi_object *obj = NULL;
>         struct bios_args *args = NULL;
> -       u32 mid, actual_outsize, ret;
> +       int mid, actual_outsize, ret;
>         size_t bios_args_size;
> 
>         mid = hp_encode_outsize_for_pvsz(outsize);
> --
> 2.39.2
Hans de Goede July 26, 2023, 2:17 p.m. UTC | #2
Hi,

On 7/18/23 09:05, Dan Carpenter wrote:
> The error handling won't work if "mid" is unsigned.  "ret" is used to
> store negative error codes and declaring it as a u32 won't cause a bug
> but it's ugly.  The "actual_outsize" variable is a number between 0-4096
> so it can be declared as int as well.
> 
> Fixes: 69ea03e38f24 ("platform/x86: hp-bioscfg: biosattr-interface")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans




> ---
>  drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> index 1d59ad600b84..dea54f35b8b5 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
> @@ -123,7 +123,7 @@ int hp_wmi_perform_query(int query, enum hp_wmi_command command, void *buffer,
>  	struct bios_return *bios_return;
>  	union acpi_object *obj = NULL;
>  	struct bios_args *args = NULL;
> -	u32 mid, actual_outsize, ret;
> +	int mid, actual_outsize, ret;
>  	size_t bios_args_size;
>  
>  	mid = hp_encode_outsize_for_pvsz(outsize);
diff mbox series

Patch

diff --git a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
index 1d59ad600b84..dea54f35b8b5 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
@@ -123,7 +123,7 @@  int hp_wmi_perform_query(int query, enum hp_wmi_command command, void *buffer,
 	struct bios_return *bios_return;
 	union acpi_object *obj = NULL;
 	struct bios_args *args = NULL;
-	u32 mid, actual_outsize, ret;
+	int mid, actual_outsize, ret;
 	size_t bios_args_size;
 
 	mid = hp_encode_outsize_for_pvsz(outsize);