public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 20/34] proper use of device register
Date: Fri, 14 Aug 2009 13:25:37 +0200	[thread overview]
Message-ID: <20090814112617.235991976@de.ibm.com> (raw)
In-Reply-To: 20090814112517.982007860@de.ibm.com

[-- Attachment #1: 119-device-register.diff --]
[-- Type: text/plain, Size: 6731 bytes --]

From: Sebastian Ott <sebott@linux.vnet.ibm.com>

Don't use kfree directly after device registration started.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 drivers/char/hvc_iucv.c       |    2 +-
 drivers/s390/char/monreader.c |    2 +-
 drivers/s390/char/vmlogrdr.c  |    4 +++-
 drivers/s390/cio/chp.c        |    3 ++-
 drivers/s390/cio/css.c        |   23 ++++++++---------------
 drivers/s390/crypto/ap_bus.c  |    2 +-
 drivers/s390/net/netiucv.c    |    9 ++++++---
 drivers/s390/net/smsgiucv.c   |    6 +++---
 drivers/s390/scsi/zfcp_aux.c  |   12 ++++++++----
 9 files changed, 33 insertions(+), 30 deletions(-)

Index: quilt-2.6/drivers/char/hvc_iucv.c
===================================================================
--- quilt-2.6.orig/drivers/char/hvc_iucv.c
+++ quilt-2.6/drivers/char/hvc_iucv.c
@@ -1006,7 +1006,7 @@ static int __init hvc_iucv_alloc(int id,
 	priv->dev->release = (void (*)(struct device *)) kfree;
 	rc = device_register(priv->dev);
 	if (rc) {
-		kfree(priv->dev);
+		put_device(priv->dev);
 		goto out_error_dev;
 	}
 
Index: quilt-2.6/drivers/s390/char/monreader.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/monreader.c
+++ quilt-2.6/drivers/s390/char/monreader.c
@@ -581,7 +581,7 @@ static int __init mon_init(void)
 	monreader_device->release = (void (*)(struct device *))kfree;
 	rc = device_register(monreader_device);
 	if (rc) {
-		kfree(monreader_device);
+		put_device(monreader_device);
 		goto out_driver;
 	}
 
Index: quilt-2.6/drivers/s390/char/vmlogrdr.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/vmlogrdr.c
+++ quilt-2.6/drivers/s390/char/vmlogrdr.c
@@ -765,8 +765,10 @@ static int vmlogrdr_register_device(stru
 	} else
 		return -ENOMEM;
 	ret = device_register(dev);
-	if (ret)
+	if (ret) {
+		put_device(dev);
 		return ret;
+	}
 
 	ret = sysfs_create_group(&dev->kobj, &vmlogrdr_attr_group);
 	if (ret) {
Index: quilt-2.6/drivers/s390/cio/chp.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/chp.c
+++ quilt-2.6/drivers/s390/cio/chp.c
@@ -417,7 +417,8 @@ int chp_new(struct chp_id chpid)
 	if (ret) {
 		CIO_MSG_EVENT(0, "Could not register chp%x.%02x: %d\n",
 			      chpid.cssid, chpid.id, ret);
-		goto out_free;
+		put_device(&chp->dev);
+		goto out;
 	}
 	ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
 	if (ret) {
Index: quilt-2.6/drivers/s390/cio/css.c
===================================================================
--- quilt-2.6.orig/drivers/s390/cio/css.c
+++ quilt-2.6/drivers/s390/cio/css.c
@@ -152,18 +152,6 @@ css_alloc_subchannel(struct subchannel_i
 }
 
 static void
-css_free_subchannel(struct subchannel *sch)
-{
-	if (sch) {
-		/* Reset intparm to zeroes. */
-		sch->config.intparm = 0;
-		cio_commit_config(sch);
-		kfree(sch->lock);
-		kfree(sch);
-	}
-}
-
-static void
 css_subchannel_release(struct device *dev)
 {
 	struct subchannel *sch;
@@ -330,7 +318,7 @@ int css_probe_device(struct subchannel_i
 		return PTR_ERR(sch);
 	ret = css_register_subchannel(sch);
 	if (ret)
-		css_free_subchannel(sch);
+		put_device(&sch->dev);
 	return ret;
 }
 
@@ -647,7 +635,10 @@ __init_channel_subsystem(struct subchann
 	 * not working) so we do it now. This is true e.g. for the
 	 * console subchannel.
 	 */
-	css_register_subchannel(sch);
+	if (css_register_subchannel(sch)) {
+		if (!cio_is_console(schid))
+			put_device(&sch->dev);
+	}
 	return 0;
 }
 
@@ -923,8 +914,10 @@ init_channel_subsystem (void)
 				goto out_device;
 		}
 		ret = device_register(&css->pseudo_subchannel->dev);
-		if (ret)
+		if (ret) {
+			put_device(&css->pseudo_subchannel->dev);
 			goto out_file;
+		}
 	}
 	ret = register_reboot_notifier(&css_reboot_notifier);
 	if (ret)
Index: quilt-2.6/drivers/s390/crypto/ap_bus.c
===================================================================
--- quilt-2.6.orig/drivers/s390/crypto/ap_bus.c
+++ quilt-2.6/drivers/s390/crypto/ap_bus.c
@@ -1114,7 +1114,7 @@ static void ap_scan_bus(struct work_stru
 		ap_dev->device.release = ap_device_release;
 		rc = device_register(&ap_dev->device);
 		if (rc) {
-			kfree(ap_dev);
+			put_device(&ap_dev->device);
 			continue;
 		}
 		/* Add device attributes. */
Index: quilt-2.6/drivers/s390/net/netiucv.c
===================================================================
--- quilt-2.6.orig/drivers/s390/net/netiucv.c
+++ quilt-2.6/drivers/s390/net/netiucv.c
@@ -1839,9 +1839,10 @@ static int netiucv_register_device(struc
 		return -ENOMEM;
 
 	ret = device_register(dev);
-
-	if (ret)
+	if (ret) {
+		put_device(dev);
 		return ret;
+	}
 	ret = netiucv_add_files(dev);
 	if (ret)
 		goto out_unreg;
@@ -2226,8 +2227,10 @@ static int __init netiucv_init(void)
 	netiucv_dev->release = (void (*)(struct device *))kfree;
 	netiucv_dev->driver = &netiucv_driver;
 	rc = device_register(netiucv_dev);
-	if (rc)
+	if (rc) {
+		put_device(netiucv_dev);
 		goto out_driver;
+	}
 	netiucv_banner();
 	return rc;
 
Index: quilt-2.6/drivers/s390/net/smsgiucv.c
===================================================================
--- quilt-2.6.orig/drivers/s390/net/smsgiucv.c
+++ quilt-2.6/drivers/s390/net/smsgiucv.c
@@ -219,13 +219,13 @@ static int __init smsg_init(void)
 	smsg_dev->driver = &smsg_driver;
 	rc = device_register(smsg_dev);
 	if (rc)
-		goto out_free_dev;
+		goto out_put;
 
 	cpcmd("SET SMSG IUCV", NULL, 0, NULL);
 	return 0;
 
-out_free_dev:
-	kfree(smsg_dev);
+out_put:
+	put_device(smsg_dev);
 out_free_path:
 	iucv_path_free(smsg_path);
 	smsg_path = NULL;
Index: quilt-2.6/drivers/s390/scsi/zfcp_aux.c
===================================================================
--- quilt-2.6.orig/drivers/s390/scsi/zfcp_aux.c
+++ quilt-2.6/drivers/s390/scsi/zfcp_aux.c
@@ -306,8 +306,10 @@ struct zfcp_unit *zfcp_unit_enqueue(stru
 	}
 	read_unlock_irq(&zfcp_data.config_lock);
 
-	if (device_register(&unit->sysfs_device))
-		goto err_out_free;
+	if (device_register(&unit->sysfs_device)) {
+		put_device(&unit->sysfs_device);
+		return ERR_PTR(-EINVAL);
+	}
 
 	if (sysfs_create_group(&unit->sysfs_device.kobj,
 			       &zfcp_sysfs_unit_attrs)) {
@@ -637,8 +639,10 @@ struct zfcp_port *zfcp_port_enqueue(stru
 	}
 	read_unlock_irq(&zfcp_data.config_lock);
 
-	if (device_register(&port->sysfs_device))
-		goto err_out_free;
+	if (device_register(&port->sysfs_device)) {
+		put_device(&port->sysfs_device);
+		goto err_out;
+	}
 
 	retval = sysfs_create_group(&port->sysfs_device.kobj,
 				    &zfcp_sysfs_port_attrs);

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


  parent reply	other threads:[~2009-08-14 11:33 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 11:25 [patch 00/34] s390 patch queue for the merge window of 2.6.32 Martin Schwidefsky
2009-08-14 11:25 ` [patch 01/34] cio: fix ineffective verify event Martin Schwidefsky
2009-08-14 11:25 ` [patch 02/34] cio: move scsw helper functions to header file Martin Schwidefsky
2009-08-14 11:25 ` [patch 03/34] cio: consolidate subchannel intparm reset Martin Schwidefsky
2009-08-14 11:25 ` [patch 04/34] cio: fix not oper handling after failed line processing Martin Schwidefsky
2009-08-14 11:25 ` [patch 05/34] cio: fix double free after failed device initialization Martin Schwidefsky
2009-08-14 11:25 ` [patch 06/34] qdio: continue polling if the queue is not finished Martin Schwidefsky
2009-08-14 11:25 ` [patch 07/34] cio: ensure to hold a reference for deferred deregistration Martin Schwidefsky
2009-08-14 11:25 ` [patch 08/34] qdio: remove limited number of debugfs entries Martin Schwidefsky
2009-08-14 11:25 ` [patch 09/34] dasd: fail requests when device state is less then ready Martin Schwidefsky
2009-08-14 11:25 ` [patch 10/34] dasd: optimize cpu usage in goodcase Martin Schwidefsky
2009-08-14 11:25 ` [patch 11/34] dasd: fix message naming Martin Schwidefsky
2009-08-14 11:25 ` [patch 12/34] drivers/s390: put NULL test before dereference Martin Schwidefsky
2009-08-14 11:25 ` [patch 13/34] introduce get_clock_monotonic Martin Schwidefsky
2009-08-14 11:25 ` [patch 14/34] convert/optimize csum_fold() to C Martin Schwidefsky
2009-08-14 11:25 ` [patch 15/34] improve mcount code Martin Schwidefsky
2009-08-14 11:25 ` [patch 16/34] atomic ops: add effecient atomic64 support for 31 bit Martin Schwidefsky
2009-08-14 11:25 ` [patch 17/34] atomic ops: small cleanups Martin Schwidefsky
2009-08-14 11:25 ` [patch 18/34] hibernation: remove dead file Martin Schwidefsky
2009-08-14 11:25 ` [patch 19/34] hibernation: merge files and move to kernel/ Martin Schwidefsky
2009-08-14 11:25 ` Martin Schwidefsky [this message]
2009-08-14 11:25 ` [patch 21/34] tape: use init_timer_on_stack() rather than init_timer() Martin Schwidefsky
2009-08-14 11:25 ` [patch 22/34] kernel: Append scpdata to kernel boot command line Martin Schwidefsky
2009-08-14 11:25 ` [patch 23/34] kernel: Convert upper case scpdata to lower case Martin Schwidefsky
2009-08-14 11:25 ` [patch 24/34] move (io|sysc)_restore_trace_psw into .data section Martin Schwidefsky
2009-08-14 11:25 ` [patch 25/34] Use macros for .data.page_aligned Martin Schwidefsky
2009-08-14 11:25 ` [patch 26/34] clean up linker script using new linker script macros Martin Schwidefsky
2009-08-14 11:25 ` [patch 27/34] kernel: always keep machine flags in lowcore Martin Schwidefsky
2009-08-14 11:25 ` [patch 28/34] remove unused irq_cpustat_t defintion Martin Schwidefsky
2009-08-14 11:25 ` [patch 29/34] add call home support Martin Schwidefsky
2009-08-14 11:25 ` [patch 30/34] hypfs: remove useless variable qname Martin Schwidefsky
2009-08-14 11:25 ` [patch 31/34] vmur: Invalid allocation sequence for vmur class Martin Schwidefsky
2009-08-14 11:25 ` [patch 32/34] xpram: Remove checksum validation for suspend/resume Martin Schwidefsky
2009-08-14 11:25 ` [patch 33/34] zcrypt: Use spin_lock_bh in suspend callback Martin Schwidefsky
2009-08-14 11:25 ` [patch 34/34] kernel: Set preferred s390 console based on conmode Martin Schwidefsky

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=20090814112617.235991976@de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sebott@linux.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