Re: [PATCH] iavf: Fix null pointer dereference in iavf_print_link_message

From: Kunwu Chan
Date: Thu Dec 14 2023 - 01:46:25 EST


Thanks for your reply.
Sure, the only thing 'iavf_print_link_message' do is to print a msg by netdev_info.

The 'iavf_virtchnl_completion' assume that no errors will be returned.
Whether we could just execute 'netdev_info(netdev, "NIC Link is Up Speed is %s Full Duplex\n", speed? speed :"");' when 'speed' is null.


Before commit '1978d3ead82c8', the buffer size is '#define IAVF_MAX_SPEED_STRLEN 13', whether we could use a bigger buffer
size to avoid a null pointer.

Such as '#define IAVF_MAX_SPEED_STRLEN 48'.


On 2023/12/13 05:28, 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.