Re: [PATCH] iavf: Fix null pointer dereference in iavf_print_link_message
From: Jesse Brandeburg
Date: Tue Dec 12 2023 - 18:08:07 EST
On 12/12/2023 1:28 PM, Jakub Kicinski wrote:
> On Mon, 11 Dec 2023 10:59:27 +0800 Kunwu Chan wrote:
>> kasprintf() returns a pointer to dynamically allocated memory
>> which can be NULL upon failure.
>>
>> Fixes: 1978d3ead82c ("intel: fix string truncation warnings")
>
> No need for the allocation here, print to a buffer on the stack.
Sure, but I think that just takes us full circle back to where we
started. reverting this to the previous code will add back W=1 warnings.
The whole point of the commit mentioned above was to get a reasonable
implementation that won't cause string truncation warnings. Is there
some trick I don't know about to get an allocation which will not
trigger snprintf and friends to print warnings from -Wformat-truncation
> drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:60: warning: ‘%s’ directive output may be truncated writing 4 bytes into a region of size between 1 and 11 [-Wformat-truncation=]
> drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:1425:17: note: ‘snprintf’ output between 7 and 17 bytes into a destination of size 13
However the original warnings were for "%s" in strings. There should be
a good way, but I don't know it so could use some help.
-Jesse