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


Groups > linux.kernel > #1641617

[PATCH 1/4] pcmcia: pd6729: Use kcalloc() in pd6729_pci_probe()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/4] pcmcia: pd6729: Use kcalloc() in pd6729_pci_probe()
Date 2017-05-15 14:30 +0200
Message-ID <tHnip-8aQ-9@gated-at.bofh.it> (permalink)
References <tHnip-8aQ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 May 2017 11:41:00 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  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/pcmcia/pd6729.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 0f70b4d58f9e..289a5e74e852 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -628,6 +628,5 @@ static int pd6729_pci_probe(struct pci_dev *dev,
 	char configbyte;
 	struct pd6729_socket *socket;
 
-	socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
-			 GFP_KERNEL);
+	socket = kcalloc(MAX_SOCKETS, sizeof(*socket), GFP_KERNEL);
 	if (!socket) {
-- 
2.13.0

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


Thread

[PATCH 0/4] PCMCIA-PD6729: Adjustments for four function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-15 14:30 +0200
  [PATCH 3/4] pcmcia: pd6729: Add the macro "pr_fmt" SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-15 14:30 +0200
  [PATCH 1/4] pcmcia: pd6729: Use kcalloc() in pd6729_pci_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-15 14:30 +0200
  [PATCH 4/4] pcmcia: pd6729: Combine substrings for six messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-15 14:40 +0200

csiph-web