Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1558617

[PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe()
Date 2017-01-13 18:30 +0100
Message-ID <sZdPQ-3DF-23@gated-at.bofh.it> (permalink)
References <sZdwt-3x7-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 15:46:35 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

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 0488b7c7cc19..4bba39e70c7b 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1541,11 +1541,11 @@ static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int i;
 	struct pch_pd_dev_save *pd_dev_save;
 
-	pd_dev_save = kzalloc(sizeof(struct pch_pd_dev_save), GFP_KERNEL);
+	pd_dev_save = kzalloc(sizeof(*pd_dev_save), GFP_KERNEL);
 	if (!pd_dev_save)
 		return -ENOMEM;
 
-	board_dat = kzalloc(sizeof(struct pch_spi_board_data), GFP_KERNEL);
+	board_dat = kzalloc(sizeof(*board_dat), GFP_KERNEL);
 	if (!board_dat) {
 		retval = -ENOMEM;
 		goto err_no_mem;
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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