Skip to content

Commit

Permalink
media: tm6000: Fix sizeof() mismatches
Browse files Browse the repository at this point in the history
[ Upstream commit a08ad63 ]

The are two instances of sizeof() being used incorrectly. The
sizeof(void *) is incorrect because urb_buffer is a char ** pointer,
fix this by using sizeof(*dev->urb_buffer).  The sizeof(dma_addr_t *)
is incorrect, it should be sizeof(*dev->urb_dma), which is a dma_addr_t
and not a dma_addr_t *.  This errors did not cause any issues because
it just so happens the sizes are the same.

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")

Fixes: 16427fa ("[media] tm6000: Add parameter to keep urb bufs allocated")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Colin Ian King authored and gregkh committed Dec 30, 2020
1 parent 1638c7e commit 06a3c11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/media/usb/tm6000/tm6000-video.c
Expand Up @@ -461,11 +461,12 @@ static int tm6000_alloc_urb_buffers(struct tm6000_core *dev)
if (dev->urb_buffer)
return 0;

dev->urb_buffer = kmalloc_array(num_bufs, sizeof(void *), GFP_KERNEL);
dev->urb_buffer = kmalloc_array(num_bufs, sizeof(*dev->urb_buffer),
GFP_KERNEL);
if (!dev->urb_buffer)
return -ENOMEM;

dev->urb_dma = kmalloc_array(num_bufs, sizeof(dma_addr_t *),
dev->urb_dma = kmalloc_array(num_bufs, sizeof(*dev->urb_dma),
GFP_KERNEL);
if (!dev->urb_dma)
return -ENOMEM;
Expand Down

0 comments on commit 06a3c11

Please sign in to comment.