From: Vasiliy Kulikov <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: Christof Schmitt <christof.schmitt@de.ibm.com>,
Swen Schillig <swen@vnet.ibm.com>,
linux390@de.ibm.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
James Bottomley <James.Bottomley@suse.de>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 01/14] s390: scsi: fix error path
Date: Sun, 19 Sep 2010 12:54:36 +0000 [thread overview]
Message-ID: <1284900877-24201-1-git-send-email-segooon@gmail.com> (raw)
zfcp_unit_add() doesn't free all allocated resources in error case.
Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
I cannot compile this driver, so it is not tested at all.
drivers/s390/scsi/zfcp_unit.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index 1119c53..8eb4046 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -119,6 +119,7 @@ static void zfcp_unit_release(struct device *dev)
int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
{
struct zfcp_unit *unit;
+ int err;
unit = zfcp_unit_find(port, fcp_lun);
if (unit) {
@@ -136,21 +137,20 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
unit->dev.release = zfcp_unit_release;
INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work);
- if (dev_set_name(&unit->dev, "0x%016llx",
- (unsigned long long) fcp_lun)) {
- kfree(unit);
- return -ENOMEM;
- }
+ err = dev_set_name(&unit->dev, "0x%016llx",
+ (unsigned long long) fcp_lun);
+ if (err)
+ goto err_free;
- if (device_register(&unit->dev)) {
+ err = device_register(&unit->dev);
+ if (err) {
put_device(&unit->dev);
- return -ENOMEM;
+ goto err_free;
}
- if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs)) {
- device_unregister(&unit->dev);
- return -EINVAL;
- }
+ err = sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs);
+ if (err)
+ goto err_unreg;
get_device(&port->dev);
@@ -161,6 +161,12 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
zfcp_unit_scsi_scan(unit);
return 0;
+
+err_unreg:
+ device_unregister(&unit->dev);
+err_free:
+ kfree(unit);
+ return err;
}
/**
--
1.7.0.4
next reply other threads:[~2010-09-19 12:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 12:54 Vasiliy Kulikov [this message]
2010-09-27 13:14 ` [PATCH 01/14] s390: scsi: fix error path 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=1284900877-24201-1-git-send-email-segooon@gmail.com \
--to=segooon@gmail.com \
--cc=James.Bottomley@suse.de \
--cc=christof.schmitt@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=schwidefsky@de.ibm.com \
--cc=swen@vnet.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