Re: [PATCH v2] platform/mellanox: mlxbf-tmfifo: Fix a warning message

From: Hans de Goede
Date: Wed Oct 18 2023 - 09:42:59 EST


Hi,

On 10/13/23 01:02, Liming Sun wrote:
> This commit fixes the smatch static checker warning in function
> mlxbf_tmfifo_rxtx_word() which complains data not initialized at
> line 634 when IS_VRING_DROP() is TRUE.
>
> Signed-off-by: Liming Sun <limings@xxxxxxxxxx>
> ---
> v1->v2: Logic adjustment for Hans's comment
> - Adjust the logic to avoid confusion.

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

I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.

Regards,

Hans






> v1: Initial version.
> ---
> drivers/platform/mellanox/mlxbf-tmfifo.c | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
> index f3696a54a2bd..d9615ad60012 100644
> --- a/drivers/platform/mellanox/mlxbf-tmfifo.c
> +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
> @@ -607,24 +607,25 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring,
>
> if (vring->cur_len + sizeof(u64) <= len) {
> /* The whole word. */
> - if (!IS_VRING_DROP(vring)) {
> - if (is_rx)
> + if (is_rx) {
> + if (!IS_VRING_DROP(vring))
> memcpy(addr + vring->cur_len, &data,
> sizeof(u64));
> - else
> - memcpy(&data, addr + vring->cur_len,
> - sizeof(u64));
> + } else {
> + memcpy(&data, addr + vring->cur_len,
> + sizeof(u64));
> }
> vring->cur_len += sizeof(u64);
> } else {
> /* Leftover bytes. */
> - if (!IS_VRING_DROP(vring)) {
> - if (is_rx)
> + if (is_rx) {
> + if (!IS_VRING_DROP(vring))
> memcpy(addr + vring->cur_len, &data,
> len - vring->cur_len);
> - else
> - memcpy(&data, addr + vring->cur_len,
> - len - vring->cur_len);
> + } else {
> + data = 0;
> + memcpy(&data, addr + vring->cur_len,
> + len - vring->cur_len);
> }
> vring->cur_len = len;
> }