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

From: SF Markus Elfring
Date: Wed Jan 18 2017 - 17:01:35 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
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