lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 16 Oct 2017 14:19:39 +0200
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     "David S. Miller" <davem@...emloft.net>,
        Jarod Wilson <jarod@...hat.com>,
        Johannes Berg <johannes.berg@...el.com>,
        Stephen Hemminger <stephen@...workplumber.org>,
        kernel-janitors@...r.kernel.org
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] char/pcmcia: Improve nine size determinations

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 16 Oct 2017 13:33:04 +0200

Replace the specification of data types by variable references
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/char/pcmcia/synclink_cs.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 4db7eda2e7f2..6c210b5cdf69 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -519,7 +519,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("mgslpc_attach\n");
 
-	info = kzalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -534,7 +534,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
 	init_waitqueue_head(&info->event_wait_q);
 	spin_lock_init(&info->lock);
 	spin_lock_init(&info->netlock);
-	memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS));
+	memcpy(&info->params, &default_params, sizeof(default_params));
 	info->idle_mode = HDLC_TXIDLE_FLAGS;
 	info->imra_value = 0xffff;
 	info->imrb_value = 0xffff;
@@ -1771,7 +1771,8 @@ static int get_stats(MGSLPC_INFO * info, struct mgsl_icount __user *user_icount)
 	if (!user_icount) {
 		memset(&info->icount, 0, sizeof(info->icount));
 	} else {
-		COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount));
+		COPY_TO_USER(err, user_icount, &info->icount,
+			     sizeof(*user_icount));
 		if (err)
 			return -EFAULT;
 	}
@@ -1785,7 +1786,7 @@ static int get_params(MGSLPC_INFO * info, MGSL_PARAMS __user *user_params)
 	int err;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("get_params(%s)\n", info->device_name);
-	COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS));
+	COPY_TO_USER(err, user_params, &info->params, sizeof(*user_params));
 	if (err)
 		return -EFAULT;
 	return 0;
@@ -1809,7 +1810,7 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params, struct
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):set_params %s\n", __FILE__,__LINE__,
 			info->device_name);
-	COPY_FROM_USER(err,&tmp_params, new_params, sizeof(MGSL_PARAMS));
+	COPY_FROM_USER(err, &tmp_params, new_params, sizeof(tmp_params));
 	if (err) {
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):set_params(%s) user buffer copy failed\n",
@@ -1818,7 +1819,7 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params, struct
 	}
 
 	spin_lock_irqsave(&info->lock, flags);
-	memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS));
+	memcpy(&info->params, &tmp_params, sizeof(tmp_params));
 	spin_unlock_irqrestore(&info->lock, flags);
 
 	mgslpc_change_params(info, tty);
@@ -1831,7 +1832,7 @@ static int get_txidle(MGSLPC_INFO * info, int __user *idle_mode)
 	int err;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("get_txidle(%s)=%d\n", info->device_name, info->idle_mode);
-	COPY_TO_USER(err,idle_mode, &info->idle_mode, sizeof(int));
+	COPY_TO_USER(err, idle_mode, &info->idle_mode, sizeof(*idle_mode));
 	if (err)
 		return -EFAULT;
 	return 0;
@@ -1854,7 +1855,7 @@ static int get_interface(MGSLPC_INFO * info, int __user *if_mode)
 	int err;
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("get_interface(%s)=%d\n", info->device_name, info->if_mode);
-	COPY_TO_USER(err,if_mode, &info->if_mode, sizeof(int));
+	COPY_TO_USER(err, if_mode, &info->if_mode, sizeof(*if_mode));
 	if (err)
 		return -EFAULT;
 	return 0;
@@ -1959,7 +1960,7 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr)
 	struct	_input_signal_events oldsigs, newsigs;
 	DECLARE_WAITQUEUE(wait, current);
 
-	COPY_FROM_USER(rc,&mask, mask_ptr, sizeof(int));
+	COPY_FROM_USER(rc, &mask, mask_ptr, sizeof(mask));
 	if (rc)
 		return  -EFAULT;
 
-- 
2.14.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ