mirror of https://gitee.com/openkylin/linux.git
dmaengine: ti: k3-udma: Use struct_size() in kzalloc()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Link: https://lore.kernel.org/r/20200619224334.GA7857@embeddedor Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
db375dcb12
commit
ace52a8c2d
|
@ -2171,7 +2171,7 @@ udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl,
|
||||||
u32 ring_id;
|
u32 ring_id;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
d = kzalloc(sizeof(*d) + sglen * sizeof(d->hwdesc[0]), GFP_NOWAIT);
|
d = kzalloc(struct_size(d, hwdesc, sglen), GFP_NOWAIT);
|
||||||
if (!d)
|
if (!d)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -2487,7 +2487,7 @@ udma_prep_dma_cyclic_pkt(struct udma_chan *uc, dma_addr_t buf_addr,
|
||||||
if (period_len >= SZ_4M)
|
if (period_len >= SZ_4M)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
d = kzalloc(sizeof(*d) + periods * sizeof(d->hwdesc[0]), GFP_NOWAIT);
|
d = kzalloc(struct_size(d, hwdesc, periods), GFP_NOWAIT);
|
||||||
if (!d)
|
if (!d)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue