Skip to content

Commit

Permalink
[SCSI] zfcp: fix kfree handling in zfcp_init_device_setup
Browse files Browse the repository at this point in the history
The pointer that is allocated with kmalloc() is passed to strsep()
which modifies it. Later on the modified pointer value will be passed
to kfree. Save the original pointer and pass that one to kfree
instead.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
heicarst authored and James Bottomley committed Oct 22, 2009
1 parent 37e6ba0 commit d10c085
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/s390/scsi/zfcp_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
static void __init zfcp_init_device_setup(char *devstr)
{
char *token;
char *str;
char *str, *str_saved;
char busid[ZFCP_BUS_ID_SIZE];
u64 wwpn, lun;

/* duplicate devstr and keep the original for sysfs presentation*/
str = kmalloc(strlen(devstr) + 1, GFP_KERNEL);
str_saved = kmalloc(strlen(devstr) + 1, GFP_KERNEL);
str = str_saved;
if (!str)
return;

Expand All @@ -152,12 +153,12 @@ static void __init zfcp_init_device_setup(char *devstr)
if (!token || strict_strtoull(token, 0, (unsigned long long *) &lun))
goto err_out;

kfree(str);
kfree(str_saved);
zfcp_init_device_configure(busid, wwpn, lun);
return;

err_out:
kfree(str);
err_out:
kfree(str_saved);
pr_err("%s is not a valid SCSI device\n", devstr);
}

Expand Down

0 comments on commit d10c085

Please sign in to comment.