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


Groups > linux.kernel > #1562202 > unrolled thread

[PATCH 3/5] um: port: Improve size determinations in port_data()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-01-18 23:00 +0100
Last post2017-01-18 23:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/5] um: port: Improve size determinations in port_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 23:00 +0100

#1562202 — [PATCH 3/5] um: port: Improve size determinations in port_data()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-01-18 23:00 +0100
Subject[PATCH 3/5] um: port: Improve size determinations in port_data()
Message-ID<t16qR-15L-13@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 22:20:14 +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>
---
 arch/um/drivers/port_kern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index c96741e920f5..60c1b43a8381 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -166,7 +166,7 @@ void *port_data(int port_num)
 		if (port->port == port_num)
 			goto found;
 	}
-	port = kmalloc(sizeof(struct port_list), GFP_KERNEL);
+	port = kmalloc(sizeof(*port), GFP_KERNEL);
 	if (!port)
 		goto out;
 
@@ -196,7 +196,7 @@ void *port_data(int port_num)
 	list_add(&port->list, &ports);
 
  found:
-	dev = kmalloc(sizeof(struct port_dev), GFP_KERNEL);
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		goto out;
 
-- 
2.11.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web