RE: [bug report] platform/mellanox: Add BlueField-3 support in the tmfifo driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks! 

There is no functionality issue. IS_VRING_DROP is only set for Rx. Line 634 is for Tx. So there is no case for line 634 to be used when IS_VRING_DROP() is TRUE.

But I'll submit a patch today to eliminate the warning.

Thanks,
Liming

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Sent: Thursday, September 28, 2023 8:23 AM
> To: Liming Sun <limings@xxxxxxxxxx>
> Cc: platform-driver-x86@xxxxxxxxxxxxxxx
> Subject: [bug report] platform/mellanox: Add BlueField-3 support in the tmfifo
> driver
> 
> Hello Liming Sun,
> 
> The patch bc05ea63b394: "platform/mellanox: Add BlueField-3 support
> in the tmfifo driver" from Oct 18, 2022 (linux-next), leads to the
> following Smatch static checker warning:
> 
> 	drivers/platform/mellanox/mlxbf-tmfifo.c:634
> mlxbf_tmfifo_rxtx_word()
> 	error: uninitialized symbol 'data'.
> 
> drivers/platform/mellanox/mlxbf-tmfifo.c
>     592 static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring,
>     593                                    struct vring_desc *desc,
>     594                                    bool is_rx, int len)
>     595 {
>     596         struct virtio_device *vdev = vring->vq->vdev;
>     597         struct mlxbf_tmfifo *fifo = vring->fifo;
>     598         void *addr;
>     599         u64 data;
>     600
>     601         /* Get the buffer address of this desc. */
>     602         addr = phys_to_virt(virtio64_to_cpu(vdev, desc->addr));
>     603
>     604         /* Read a word from FIFO for Rx. */
>     605         if (is_rx)
>     606                 data = readq(fifo->rx.data);
>     607
>     608         if (vring->cur_len + sizeof(u64) <= len) {
>     609                 /* The whole word. */
>     610                 if (!IS_VRING_DROP(vring)) {
>     611                         if (is_rx)
>     612                                 memcpy(addr + vring->cur_len, &data,
>     613                                        sizeof(u64));
>     614                         else
>     615                                 memcpy(&data, addr + vring->cur_len,
>     616                                        sizeof(u64));
>     617                 }
> 
> if IS_VRING_DROP() is true then data isn't intialized.
> 
>     618                 vring->cur_len += sizeof(u64);
>     619         } else {
>     620                 /* Leftover bytes. */
>     621                 if (!IS_VRING_DROP(vring)) {
>     622                         if (is_rx)
>     623                                 memcpy(addr + vring->cur_len, &data,
>     624                                        len - vring->cur_len);
>     625                         else
>     626                                 memcpy(&data, addr + vring->cur_len,
>     627                                        len - vring->cur_len);
>     628                 }
> 
> Same here.
> 
>     629                 vring->cur_len = len;
>     630         }
>     631
>     632         /* Write the word into FIFO for Tx. */
>     633         if (!is_rx)
> --> 634                 writeq(data, fifo->tx.data);
>                                ^^^^
> Unitialized if IS_VRING_DROP() is true.
> 
>     635 }
> 
> regards,
> dan carpenter




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux