lkml.org 
[lkml]   [2018]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 3/5] misc/pti: Improve a size determination in two functions
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 9 Jan 2018 18:28:44 +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 according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/misc/pti.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 8292e8098cc8..8ae79b286573 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -243,10 +243,9 @@ static struct pti_masterchannel *get_id(u8 *id_array,
int base_id,
const char *thread_name)
{
- struct pti_masterchannel *mc;
int i, j, mask;
+ struct pti_masterchannel *mc = kmalloc(sizeof(*mc), GFP_KERNEL);

- mc = kmalloc(sizeof(struct pti_masterchannel), GFP_KERNEL);
if (mc == NULL)
return NULL;

@@ -465,7 +464,7 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
int ret = tty_standard_install(driver, tty);

if (ret == 0) {
- pti_tty_data = kmalloc(sizeof(struct pti_tty), GFP_KERNEL);
+ pti_tty_data = kmalloc(sizeof(*pti_tty_data), GFP_KERNEL);
if (pti_tty_data == NULL)
return -ENOMEM;

--
2.15.1
\
 
 \ /
  Last update: 2018-01-14 23:20    [W:0.049 / U:4.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site