[PATCH] lib: fwts_memorymap: handle the case where str maybe NULL

IvanHu ivan.hu at canonical.com
Thu May 16 03:35:07 UTC 2013


On 05/07/2013 07:32 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997294, Dereference after null check (FORWARD_NULL)
>
> str may be null, in which case we should only parse for end
> and register a memory map line if str is not NULL.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_memorymap.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
> index 6e8bc1e..e619627 100644
> --- a/src/lib/src/fwts_memorymap.c
> +++ b/src/lib/src/fwts_memorymap.c
> @@ -185,11 +185,12 @@ static void fwts_memory_map_dmesg_info(void *data, void *private)
>
>   		start = strtoull(str+10, NULL, 16);
>   		str = strstr(line," - ");
> -		if (str)
> +		if (str) {
>   			str += 3;
> -		end   = strtoull(str, NULL, 16) - 1;
> +			end = strtoull(str, NULL, 16) - 1;
>
> -		fwts_register_memory_map_line(memory_map_list, start, end, fwts_memory_map_str_to_type(line));
> +			fwts_register_memory_map_line(memory_map_list, start, end, fwts_memory_map_str_to_type(line));
> +		}
>   	}
>   }
>
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list