From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@suse.de>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
Christof Schmitt <christof.schmitt@de.ibm.com>
Subject: [patch 01/10] zfcp: Use memdup_user and kstrdup
Date: Fri, 16 Jul 2010 15:37:34 +0200 [thread overview]
Message-ID: <20100716134259.870531000@de.ibm.com> (raw)
In-Reply-To: 20100716133733.621672000@de.ibm.com
[-- Attachment #1: 704-zfcp-dup.diff --]
[-- Type: text/plain, Size: 1909 bytes --]
From: Christof Schmitt <christof.schmitt@de.ibm.com>
Use the functions memdup_user and kstrdup to allocate memory and copy
the data in one step, saving some lines of code.
Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
drivers/s390/scsi/zfcp_aux.c | 4 +---
drivers/s390/scsi/zfcp_cfdc.c | 12 +++---------
2 files changed, 4 insertions(+), 12 deletions(-)
diff -urpN linux-2.6/drivers/s390/scsi/zfcp_aux.c linux-2.6-patched/drivers/s390/scsi/zfcp_aux.c
--- linux-2.6/drivers/s390/scsi/zfcp_aux.c 2010-07-15 12:21:48.000000000 +0200
+++ linux-2.6-patched/drivers/s390/scsi/zfcp_aux.c 2010-07-15 12:22:18.000000000 +0200
@@ -98,13 +98,11 @@ static void __init zfcp_init_device_setu
u64 wwpn, lun;
/* duplicate devstr and keep the original for sysfs presentation*/
- str_saved = kmalloc(strlen(devstr) + 1, GFP_KERNEL);
+ str_saved = kstrdup(devstr, GFP_KERNEL);
str = str_saved;
if (!str)
return;
- strcpy(str, devstr);
-
token = strsep(&str, ",");
if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
goto err_out;
diff -urpN linux-2.6/drivers/s390/scsi/zfcp_cfdc.c linux-2.6-patched/drivers/s390/scsi/zfcp_cfdc.c
--- linux-2.6/drivers/s390/scsi/zfcp_cfdc.c 2010-07-15 12:21:48.000000000 +0200
+++ linux-2.6-patched/drivers/s390/scsi/zfcp_cfdc.c 2010-07-15 12:22:18.000000000 +0200
@@ -189,18 +189,12 @@ static long zfcp_cfdc_dev_ioctl(struct f
if (!fsf_cfdc)
return -ENOMEM;
- data = kmalloc(sizeof(struct zfcp_cfdc_data), GFP_KERNEL);
- if (!data) {
- retval = -ENOMEM;
+ data = memdup_user(data_user, sizeof(*data_user));
+ if (IS_ERR(data)) {
+ retval = PTR_ERR(data);
goto no_mem_sense;
}
- retval = copy_from_user(data, data_user, sizeof(*data));
- if (retval) {
- retval = -EFAULT;
- goto free_buffer;
- }
-
if (data->signature != 0xCFDCACDF) {
retval = -EINVAL;
goto free_buffer;
next prev parent reply other threads:[~2010-07-16 13:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-16 13:37 [patch 00/10] zfcp updates for 2.6.36 merge window Christof Schmitt
2010-07-16 13:37 ` Christof Schmitt [this message]
2010-07-16 13:37 ` [patch 02/10] zfcp: Remove SCSI device when removing unit Christof Schmitt
2010-07-27 20:37 ` James Bottomley
2010-07-28 8:35 ` Christof Schmitt
2010-07-16 13:37 ` [patch 03/10] zfcp: Use correct width for timer_interval field Christof Schmitt
2010-07-16 13:37 ` [patch 04/10] zfcp: Cleanup function parameters for sbal value Christof Schmitt
2010-07-16 13:37 ` [patch 05/10] zfcp: Cleanup QDIO attachment and improve processing Christof Schmitt
2010-07-16 13:37 ` [patch 06/10] zfcp: Post events through FC transport class Christof Schmitt
2010-07-16 13:37 ` [patch 07/10] zfcp: Prevent access on uninitialized memory Christof Schmitt
2010-07-16 13:37 ` [patch 08/10] zfcp: Enable data division support for FCP devices Christof Schmitt
2010-07-16 13:37 ` [patch 09/10] zfcp: Introduce experimental support for DIF/DIX Christof Schmitt
2010-07-16 13:37 ` [patch 10/10] zfcp: Trigger logging in the FCP channel on qdio error conditions Christof Schmitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100716134259.870531000@de.ibm.com \
--to=christof.schmitt@de.ibm.com \
--cc=James.Bottomley@suse.de \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).