From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752897AbdJPMT7 (ORCPT ); Mon, 16 Oct 2017 08:19:59 -0400 Received: from mout.web.de ([212.227.17.12]:49587 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbdJPMTz (ORCPT ); Mon, 16 Oct 2017 08:19:55 -0400 Subject: [PATCH 2/3] char/pcmcia: Improve nine size determinations From: SF Markus Elfring To: "David S. Miller" , Jarod Wilson , Johannes Berg , Stephen Hemminger , kernel-janitors@vger.kernel.org Cc: LKML References: <5e693086-a995-81ad-4a3f-cf8ab2bac454@users.sourceforge.net> Message-ID: Date: Mon, 16 Oct 2017 14:19:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <5e693086-a995-81ad-4a3f-cf8ab2bac454@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:mMLc5OHjg4N6uS+Mr2Rl92XBU9eadX39ntwt9vZFqTymTZS00Ag 1JoWeuxne8ds5MhGwvdFtmQAIRa4HsdyGhGCBEQ1cCDFu/mGri4XUt2yQWJIFpakUIv0lYC 5p3ueP3rNSuSbIPBfzB3BD5WrQKrH8d8Zi39mpD+jlDq38nzhfIO69g7+TkhMdCcK3HY2qr WMhLpVYQO2BdypBeYscsw== X-UI-Out-Filterresults: notjunk:1;V01:K0:M5hFZpq8iEc=:UsToKD10zgnJZDg5+0ESAw 9A37NmKJuYckYD3j62FFsrtejEFgqvZuXMycn0bEi+l6PYjFgT6/WcQ7c0/dZsrUE4fYczfA6 G87QQiApk858WKSHMjES/GtWhRHEEw+vaKAXNdzWx5L6lDvmFdhvV7Ftp4Odpxz9YQOhQbFsF BBDqFTocgAaSG5GnYpGFYdR1oqMg8ZpFQUBneOlxkqRkh6Vb88dTdwGB3fPA/BRAb6cO7nFaT YHSZ1dUrHL/22gcN/U9pbJrTvd0flbrLuIL09hc01pksX7zmWqlqLrYDbNHclYUMVBArrXlOd +uEghRuBKYOlKxZ9l0oTl1IHEJw5p+9rPSDDKvh6o4G6xs5WrwuKg2Fk6iylEs6HNBCHvpmy0 FMpketgnRNWXTNo9Qz7Ic/MoM5VaMa8ZzRgvX32YlEzclLEf/m9SFEZA0wa52FWsoVuKkJGB3 kuTje2hH11uo7LrXNcvBH21Va2TcygPoHD+jVcOS5WaoRiMQ0jaUMGP0br6kdzcnJx6PfV30x 79pNXBURA3bNi06PzRpE54W7zxNBTBlgygSH5AnB3bHhO9bKdeA/EOnrJnbK4QND8dN6rCWbp KA28O6eA1IpynRR0OL5KFBL4DV7z56uAKJxk3d4NlDUIYu5nJwST0h1I+J6yqiLTlnVx6EdWK MQAv32PejLx6Q1JBVj5AV53tKwPi2gecywiPrZPv+RMlYgR5K70p0sYeW3XPOHx8eb/1QLk7c 7xcoJV5gQzbyuWFdmhzRsvyRfwhjV0lWbiTS2VWmrD6+lfgyxanovnlTxigtbKxR7xu0/eEa9 9TsNmjkZWobwOrU95jIWflv0iA4nI7OmoCqPi/nXiVp4mDdrsA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring 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 --- 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