[PATCH 3/5] misc/pti: Improve a size determination in two functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux