Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1558630
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() |
| Date | 2017-01-13 18:30 +0100 |
| Message-ID | <sZdPR-3DF-51@gated-at.bofh.it> (permalink) |
| References | <sZdwt-3x7-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 13 Jan 2017 15:25:22 +0100 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data structure by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/spi/spi-topcliff-pch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index fcb991034c3d..0488b7c7cc19 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -1008,7 +1008,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) spin_unlock_irqrestore(&data->lock, flags); /* RX */ - dma->sg_rx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC); + dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC); sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_rx_p; @@ -1068,7 +1068,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) head = 0; } - dma->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC); + dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC); sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_tx_p; -- 2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 00/17] SPI: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 01/17] spi: Use kcalloc() in spi_register_board_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 04/17] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 07/17] spi/mpc52xx: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 02/17] spi: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 03/17] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 08/17] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 09/17] spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 05/17] spi: fsl: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-13 19:20 +0100
[PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers Dan Carpenter <dan.carpenter@oracle.com> - 2017-01-14 07:40 +0100
[PATCH 16/17] spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 13/17] spi/topcliff-pch: Delete an unnecessary return statement in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 15/17] spi/topcliff-pch: Combine substrings for four messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
csiph-web