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


Groups > linux.kernel > #1562217

[PATCH 5/5] um: ubd: Improve size determinations in do_ubd_request()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 5/5] um: ubd: Improve size determinations in do_ubd_request()
Date 2017-01-18 23:10 +0100
Message-ID <t16Ay-1or-13@gated-at.bofh.it> (permalink)
References <t16qR-15L-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 22:38:04 +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/ubd_kern.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 6d686f735538..50327d5a9a01 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1386,8 +1386,7 @@ static void do_ubd_request(struct request_queue *q)
 		req = dev->request;
 
 		if (req_op(req) == REQ_OP_FLUSH) {
-			io_req = kmalloc(sizeof(struct io_thread_req),
-					 GFP_ATOMIC);
+			io_req = kmalloc(sizeof(*io_req), GFP_ATOMIC);
 			if (io_req == NULL) {
 				if (list_empty(&dev->restart))
 					list_add(&dev->restart, &restart);
@@ -1401,8 +1400,7 @@ static void do_ubd_request(struct request_queue *q)
 		while(dev->start_sg < dev->end_sg){
 			struct scatterlist *sg = &dev->sg[dev->start_sg];
 
-			io_req = kmalloc(sizeof(struct io_thread_req),
-					 GFP_ATOMIC);
+			io_req = kmalloc(sizeof(*io_req), GFP_ATOMIC);
 			if(io_req == NULL){
 				if(list_empty(&dev->restart))
 					list_add(&dev->restart, &restart);
-- 
2.11.0

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


Thread

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

csiph-web