Re: [PATCH] octeon_ep: Remove unnecessary cast
From: Joe Perches
Date: Tue Apr 19 2022 - 22:07:24 EST
On Wed, 2022-04-20 at 09:47 +0800, Haowen Bai wrote:
> Fix the following coccicheck warning:
>
> ./drivers/net/ethernet/marvell/octeon_ep/octep_rx.c:161:18-40: WARNING:
> casting value returned by memory allocation function to (struct
> octep_rx_buffer *) is useless.
[]
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
[]
> @@ -158,8 +158,7 @@ static int octep_setup_oq(struct octep_device *oct, int q_no)
> goto desc_dma_alloc_err;
> }
>
> - oq->buff_info = (struct octep_rx_buffer *)
> - vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE);
> + oq->buff_info = vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE);
> if (unlikely(!oq->buff_info)) {
> dev_err(&oct->pdev->dev,
> "Failed to allocate buffer info for OQ-%d\n", q_no);
probably better to use kvcalloc or maybe vcalloc if oq->max_count is
always expected to be huge.
OCTEP_OQ_RECVBUF_SIZE is pretty small (just a pointer and a u64).