ACK: [PATCH] acpi: add null check on calls to get_space_id_name()
ivanhu
ivan.hu at canonical.com
Wed Jan 20 01:34:38 UTC 2021
On 1/19/21 5:53 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> A null can be potentially returned from get_space_id_name() if the id is
> out of range, so add a null check. Also don't call the function multiple
> times but use a temporary char * pointer to stash the result of the call.
>
> Addresses-Coverity: ("Dereference null return")
> Fixes: ffea02df09d3 ("acpi: add fwts_acpi_space_id_check to check GAS adrress space ids")
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_acpi_tables.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 6ad1bf77..d832a65c 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1668,17 +1668,23 @@ void fwts_acpi_space_id_check(
>
> va_start(ap, num_type);
> for (i = 0; i < num_type; i++) {
> + const char *id_name;
> +
> must_be = va_arg(ap, int);
> if (actual == must_be) {
> matched = true;
> break;
> }
>
> - length += strlen(get_space_id_name(must_be));
> + id_name = get_space_id_name(must_be);
> + if (!id_name)
> + continue;
> +
> + length += strlen(id_name);
> if (length > 255)
> continue;
>
> - strncat(must_be_id, get_space_id_name(must_be), strlen(get_space_id_name(must_be)));
> + strncat(must_be_id, id_name, strlen(id_name));
> if (i < num_type - 2)
> strncat(must_be_id, ", ", 3);
> else if (i == num_type - 2)
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list