Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mailbox: rockchip: kzalloc + kcalloc to kzalloc

Use a flexible array member to reduce allocations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>

authored by

Rosen Penev and committed by
Jassi Brar
f9f0df23 57df858a

+2 -7
+2 -7
drivers/mailbox/rockchip-mailbox.c
··· 46 46 /* The maximum size of buf for each channel */ 47 47 u32 buf_size; 48 48 49 - struct rockchip_mbox_chan *chans; 49 + struct rockchip_mbox_chan chans[]; 50 50 }; 51 51 52 52 static int rockchip_mbox_send_data(struct mbox_chan *chan, void *data) ··· 173 173 174 174 drv_data = (const struct rockchip_mbox_data *) device_get_match_data(&pdev->dev); 175 175 176 - mb = devm_kzalloc(&pdev->dev, sizeof(*mb), GFP_KERNEL); 176 + mb = devm_kzalloc(&pdev->dev, struct_size(mb, chans, drv_data->num_chans), GFP_KERNEL); 177 177 if (!mb) 178 - return -ENOMEM; 179 - 180 - mb->chans = devm_kcalloc(&pdev->dev, drv_data->num_chans, 181 - sizeof(*mb->chans), GFP_KERNEL); 182 - if (!mb->chans) 183 178 return -ENOMEM; 184 179 185 180 mb->mbox.chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,