blob: 79b600266b1d54b0a68c75053cad24a5199c82be [file] [log] [blame]
Subject: driver core: fixup device_initialize() return value usages
all over the place...
---
arch/mips/kernel/vpe.c | 6 +++++-
block/genhd.c | 6 +++++-
drivers/base/attribute_container.c | 6 +++++-
drivers/hid/hid-core.c | 6 +++++-
drivers/scsi/raid_class.c | 6 +++++-
drivers/scsi/scsi_priv.h | 2 +-
drivers/scsi/scsi_scan.c | 14 ++++++++++++--
drivers/scsi/scsi_sysfs.c | 1 +
drivers/scsi/scsi_transport_fc.c | 12 ++++++++++--
drivers/scsi/scsi_transport_iscsi.c | 5 ++++-
drivers/scsi/scsi_transport_sas.c | 22 ++++++++++++++++++----
drivers/scsi/scsi_transport_srp.c | 6 +++++-
drivers/spi/spi.c | 13 +++++++++++--
drivers/usb/core/usb.c | 7 ++++++-
drivers/usb/gadget/atmel_usba_udc.c | 4 +++-
drivers/usb/gadget/fsl_qe_udc.c | 4 +++-
drivers/usb/gadget/imx_udc.c | 4 +++-
drivers/usb/gadget/lh7a40x_udc.c | 4 +++-
drivers/usb/gadget/m66592-udc.c | 4 +++-
drivers/usb/gadget/omap_udc.c | 7 ++++++-
drivers/usb/gadget/pxa25x_udc.c | 4 +++-
drivers/usb/gadget/pxa27x_udc.c | 4 +++-
drivers/usb/gadget/s3c2410_udc.c | 4 +++-
drivers/uwb/lc-dev.c | 15 ++++++++++++---
drivers/uwb/lc-rc.c | 14 +++++++++++---
drivers/uwb/uwb-internal.h | 2 +-
fs/partitions/check.c | 4 +++-
include/linux/uwb.h | 2 +-
net/bluetooth/hci_sysfs.c | 3 ++-
net/wireless/core.c | 1 +
30 files changed, 154 insertions(+), 38 deletions(-)
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1461,7 +1461,11 @@ static int __init vpe_module_init(void)
goto out_chrdev;
}
- device_initialize(&vpe_device);
+ err = device_initialize(&vpe_device);
+ if (err) {
+ printk(KERN_ERR "Initializing vpe_device failed\n");
+ goto out_class;
+ }
vpe_device.class = &vpe_class,
vpe_device.parent = NULL,
dev_set_name(&vpe_device, "vpe1");
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1197,7 +1197,11 @@ struct gendisk *alloc_disk_node(int mino
rand_initialize_disk(disk);
disk_to_dev(disk)->class = &block_class;
disk_to_dev(disk)->type = &disk_type;
- device_initialize(disk_to_dev(disk));
+ if (device_initialize(disk_to_dev(disk))) {
+ free_part_stats(&disk->part0);
+ kfree(disk);
+ return NULL;
+ }
INIT_WORK(&disk->async_notify,
media_change_notify_thread);
}
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -163,7 +163,11 @@ attribute_container_add_device(struct de
}
ic->cont = cont;
- device_initialize(&ic->classdev);
+ if (device_initialize(&ic->classdev)) {
+ dev_err(dev, "failed to initialize class container\n");
+ kfree(ic);
+ continue;
+ }
ic->classdev.parent = get_device(dev);
ic->classdev.class = cont->class;
cont->class->dev_release = attribute_container_release;
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1843,7 +1843,11 @@ struct hid_device *hid_allocate_device(v
if (hdev == NULL)
return ERR_PTR(ret);
- device_initialize(&hdev->dev);
+ ret = device_initialize(&hdev->dev);
+ if (ret) {
+ kfree(hdev);
+ return ERR_PTR(ret);
+ }
hdev->dev.release = hid_device_release;
hdev->dev.bus = &hid_bus_type;
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -235,7 +235,11 @@ int raid_component_add(struct raid_templ
return -ENOMEM;
INIT_LIST_HEAD(&rc->node);
- device_initialize(&rc->dev);
+ err = device_initialize(&rc->dev);
+ if (err) {
+ kfree(rc);
+ return err;
+ }
rc->dev.release = raid_component_release;
rc->dev.parent = get_device(component_dev);
rc->num = rd->component_count++;
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -127,7 +127,7 @@ extern int scsi_sysfs_add_sdev(struct sc
extern int scsi_sysfs_add_host(struct Scsi_Host *);
extern int scsi_sysfs_register(void);
extern void scsi_sysfs_unregister(void);
-extern void scsi_sysfs_device_initialize(struct scsi_device *);
+extern int scsi_sysfs_device_initialize(struct scsi_device *);
extern int scsi_sysfs_target_initialize(struct scsi_device *);
extern struct scsi_transport_template blank_transport_template;
extern void __scsi_remove_device(struct scsi_device *);
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -299,7 +299,12 @@ static struct scsi_device *scsi_alloc_sd
sdev->request_queue->queuedata = sdev;
scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
- scsi_sysfs_device_initialize(sdev);
+ ret = scsi_sysfs_device_initialize(sdev);
+ if (ret) {
+ put_device(&starget->dev);
+ kfree(sdev);
+ goto out;
+ }
if (shost->hostt->slave_alloc) {
ret = shost->hostt->slave_alloc(sdev);
@@ -413,7 +418,12 @@ static struct scsi_target *scsi_alloc_ta
return NULL;
}
dev = &starget->dev;
- device_initialize(dev);
+ error = device_initialize(dev);
+ if (error) {
+ printk(KERN_ERR "%s: device_initialize failure\n", __func__);
+ kfree(starget);
+ return NULL;
+ }
starget->reap_ref = 1;
dev->parent = get_device(parent);
dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1073,6 +1073,7 @@ void scsi_sysfs_device_initialize(struct
list_add_tail(&sdev->same_target_siblings, &starget->devices);
list_add_tail(&sdev->siblings, &shost->__devices);
spin_unlock_irqrestore(shost->host_lock, flags);
+ return 0;
}
int scsi_is_sdev_device(const struct device *dev)
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2611,7 +2611,11 @@ fc_rport_create(struct Scsi_Host *shost,
spin_unlock_irqrestore(shost->host_lock, flags);
dev = &rport->dev;
- device_initialize(dev); /* takes self reference */
+ error = device_initialize(dev); /* takes self reference */
+ if (error) {
+ printk(KERN_ERR "FC Remote Port device_initialize failed\n");
+ goto delete_rport;
+ }
dev->parent = get_device(&shost->shost_gendev); /* parent reference */
dev->release = fc_rport_dev_release;
dev_set_name(dev, "rport-%d:%d-%d",
@@ -3350,7 +3354,11 @@ fc_vport_setup(struct Scsi_Host *shost,
spin_unlock_irqrestore(shost->host_lock, flags);
dev = &vport->dev;
- device_initialize(dev); /* takes self reference */
+ error = device_initialize(dev); /* takes self reference */
+ if (error) { /* takes self reference */
+ printk(KERN_ERR "FC Virtual Port device_initialize failed\n");
+ goto delete_vport;
+ }
dev->parent = get_device(pdev); /* takes parent reference */
dev->release = fc_vport_dev_release;
dev_set_name(dev, "vport-%d:%d-%d",
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -726,7 +726,10 @@ iscsi_alloc_session(struct Scsi_Host *sh
scsi_host_get(shost);
session->dev.parent = &shost->shost_gendev;
session->dev.release = iscsi_session_release;
- device_initialize(&session->dev);
+ if (device_initialize(&session->dev)) {
+ kfree(session);
+ return NULL;
+ }
if (dd_size)
session->dd_data = &session[1];
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -711,7 +711,10 @@ struct sas_phy *sas_phy_alloc(struct dev
phy->number = number;
phy->enabled = 1;
- device_initialize(&phy->dev);
+ if (device_initialize(&phy->dev)) {
+ kfree(phy);
+ return NULL;
+ }
phy->dev.parent = get_device(parent);
phy->dev.release = sas_phy_release;
INIT_LIST_HEAD(&phy->port_siblings);
@@ -899,7 +902,10 @@ struct sas_port *sas_port_alloc(struct d
port->port_identifier = port_id;
- device_initialize(&port->dev);
+ if (device_initialize(&port->dev)) {
+ kfree(port);
+ return NULL;
+ }
port->dev.parent = get_device(parent);
port->dev.release = sas_port_release;
@@ -1450,7 +1456,11 @@ struct sas_rphy *sas_end_device_alloc(st
return NULL;
}
- device_initialize(&rdev->rphy.dev);
+ if (device_initialize(&rdev->rphy.dev)) {
+ kfree(rdev);
+ return NULL;
+ }
+
rdev->rphy.dev.parent = get_device(&parent->dev);
rdev->rphy.dev.release = sas_end_device_release;
if (scsi_is_sas_expander_device(parent->dev.parent)) {
@@ -1494,7 +1504,11 @@ struct sas_rphy *sas_expander_alloc(stru
return NULL;
}
- device_initialize(&rdev->rphy.dev);
+ if (device_initialize(&rdev->rphy.dev)) {
+ kfree(rdev);
+ return NULL;
+ }
+
rdev->rphy.dev.parent = get_device(&parent->dev);
rdev->rphy.dev.release = sas_expander_release;
mutex_lock(&sas_host->lock);
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -203,7 +203,11 @@ struct srp_rport *srp_rport_add(struct S
if (!rport)
return ERR_PTR(-ENOMEM);
- device_initialize(&rport->dev);
+ ret = device_initialize(&rport->dev);
+ if (ret) {
+ kfree(rport);
+ return ERR_PTR(ret);
+ }
rport->dev.parent = get_device(parent);
rport->dev.release = srp_rport_release;
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -230,6 +230,7 @@ struct spi_device *spi_alloc_device(stru
{
struct spi_device *spi;
struct device *dev = master->dev.parent;
+ int retval;
if (!spi_master_get(master))
return NULL;
@@ -245,7 +246,12 @@ struct spi_device *spi_alloc_device(stru
spi->dev.parent = dev;
spi->dev.bus = &spi_bus_type;
spi->dev.release = spidev_release;
- device_initialize(&spi->dev);
+ retval = device_initialize(&spi->dev);
+ if (retval) {
+ spi_master_put(master);
+ kfree(spi);
+ spi = NULL;
+ }
return spi;
}
EXPORT_SYMBOL_GPL(spi_alloc_device);
@@ -479,7 +485,10 @@ struct spi_master *spi_alloc_master(stru
if (!master)
return NULL;
- device_initialize(&master->dev);
+ if (device_initialize(&master->dev)) {
+ kfree(master);
+ return NULL;
+ }
master->dev.class = &spi_master_class;
master->dev.parent = get_device(dev);
spi_master_set_devdata(master, &master[1]);
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -366,6 +366,7 @@ struct usb_device *usb_alloc_dev(struct
struct usb_device *dev;
struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self);
unsigned root_hub = 0;
+ int ret;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -383,7 +384,11 @@ struct usb_device *usb_alloc_dev(struct
return NULL;
}
- device_initialize(&dev->dev);
+ ret = device_initialize(&dev->dev);
+ if (ret) {
+ kfree(dev);
+ return NULL;
+ }
dev->dev.bus = &usb_bus_type;
dev->dev.type = &usb_device_type;
dev->dev.groups = usb_device_groups;
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1930,7 +1930,9 @@ static int __init usba_udc_probe(struct
dev_info(&pdev->dev, "FIFO at 0x%08lx mapped at %p\n",
(unsigned long)fifo->start, udc->fifo);
- device_initialize(&udc->gadget.dev);
+ ret = device_initialize(&udc->gadget.dev);
+ if (ret)
+ goto err_alloc_ep;
udc->gadget.dev.parent = &pdev->dev;
udc->gadget.dev.dma_mask = pdev->dev.dma_mask;
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2569,7 +2569,9 @@ static int __devinit qe_udc_probe(struct
/* name: Identifies the controller hardware type. */
udc_controller->gadget.name = driver_name;
- device_initialize(&udc_controller->gadget.dev);
+ ret = device_initialize(&udc_controller->gadget.dev);
+ if (ret)
+ goto err2;
dev_set_name(&udc_controller->gadget.dev, "gadget");
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -1485,7 +1485,9 @@ static int __init imx_udc_probe(struct p
imx_usb->clk = clk;
imx_usb->dev = &pdev->dev;
- device_initialize(&imx_usb->gadget.dev);
+ ret = device_initialize(&imx_usb->gadget.dev);
+ if (ret)
+ goto fail3;
imx_usb->gadget.dev.parent = &pdev->dev;
imx_usb->gadget.dev.dma_mask = pdev->dev.dma_mask;
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -2073,7 +2073,9 @@ static int lh7a40x_udc_probe(struct plat
spin_lock_init(&dev->lock);
dev->dev = &pdev->dev;
- device_initialize(&dev->gadget.dev);
+ retval = device_initialize(&dev->gadget.dev);
+ if (retval)
+ return retval;
dev->gadget.dev.parent = &pdev->dev;
the_controller = dev;
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1622,7 +1622,9 @@ static int __init m66592_probe(struct pl
dev_set_drvdata(&pdev->dev, m66592);
m66592->gadget.ops = &m66592_gadget_ops;
- device_initialize(&m66592->gadget.dev);
+ ret = device_initialize(&m66592->gadget.dev);
+ if (ret)
+ goto clean_up;
dev_set_name(&m66592->gadget.dev, "gadget");
m66592->gadget.is_dualspeed = 1;
m66592->gadget.dev.parent = &pdev->dev;
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2659,6 +2659,7 @@ static int __init
omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
{
unsigned tmp, buf;
+ int ret;
/* abolish any previous hardware state */
omap_writew(0, UDC_SYSCON1);
@@ -2684,7 +2685,11 @@ omap_udc_setup(struct platform_device *o
udc->gadget.speed = USB_SPEED_UNKNOWN;
udc->gadget.name = driver_name;
- device_initialize(&udc->gadget.dev);
+ ret = device_initialize(&udc->gadget.dev);
+ if (ret) {
+ kfree(udc)
+ return ret;
+ }
dev_set_name(&udc->gadget.dev, "gadget");
udc->gadget.dev.release = omap_udc_release;
udc->gadget.dev.parent = &odev->dev;
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -2227,7 +2227,9 @@ static int __init pxa25x_udc_probe(struc
dev->timer.function = udc_watchdog;
dev->timer.data = (unsigned long) dev;
- device_initialize(&dev->gadget.dev);
+ retval = device_initialize(&dev->gadget.dev);
+ if (retval)
+ goto err_irq1;
dev->gadget.dev.parent = &pdev->dev;
dev->gadget.dev.dma_mask = pdev->dev.dma_mask;
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -2497,7 +2497,9 @@ static int __init pxa_udc_probe(struct p
goto err_map;
}
- device_initialize(&udc->gadget.dev);
+ retval = device_initialize(&udc->gadget.dev);
+ if (retval)
+ goto err_irq;
udc->gadget.dev.parent = &pdev->dev;
udc->gadget.dev.dma_mask = NULL;
udc->vbus_sensed = 0;
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1851,7 +1851,9 @@ static int s3c2410_udc_probe(struct plat
goto err_mem;
}
- device_initialize(&udc->gadget.dev);
+ retval = device_initialize(&udc->gadget.dev);
+ if (retval)
+ goto err_map;
udc->gadget.dev.parent = &pdev->dev;
udc->gadget.dev.dma_mask = pdev->dev.dma_mask;
--- a/drivers/uwb/lc-dev.c
+++ b/drivers/uwb/lc-dev.c
@@ -110,14 +110,19 @@ static void uwb_dev_sys_release(struct d
*
* Alloc, zero and call this function.
*/
-void uwb_dev_init(struct uwb_dev *uwb_dev)
+int uwb_dev_init(struct uwb_dev *uwb_dev)
{
+ int ret;
+
mutex_init(&uwb_dev->mutex);
- device_initialize(&uwb_dev->dev);
+ ret = device_initialize(&uwb_dev->dev);
+ if (ret)
+ return ret;
uwb_dev->dev.release = uwb_dev_sys_release;
uwb_dev_addr_init(&uwb_dev->dev_addr);
uwb_mac_addr_init(&uwb_dev->mac_addr);
bitmap_fill(uwb_dev->streams, UWB_NUM_GLOBAL_STREAMS);
+ return 0;
}
static ssize_t uwb_dev_EUI_48_show(struct device *dev,
@@ -435,7 +440,11 @@ void uwbd_dev_onair(struct uwb_rc *rc, s
macbuf);
return;
}
- uwb_dev_init(uwb_dev); /* This sets refcnt to one, we own it */
+ /* This sets refcnt to one, we own it */
+ result = uwb_dev_init(uwb_dev);
+ if (result)
+ goto error_dev_add;
+
uwb_dev->mac_addr = *bce->mac_addr;
uwb_dev->dev_addr = bce->dev_addr;
dev_set_name(&uwb_dev->dev, macbuf);
--- a/drivers/uwb/lc-rc.c
+++ b/drivers/uwb/lc-rc.c
@@ -85,11 +85,14 @@ static void uwb_rc_sys_release(struct de
}
-void uwb_rc_init(struct uwb_rc *rc)
+int uwb_rc_init(struct uwb_rc *rc)
{
struct uwb_dev *uwb_dev = &rc->uwb_dev;
+ int result;
- uwb_dev_init(uwb_dev);
+ result = uwb_dev_init(uwb_dev);
+ if (result)
+ return result;
rc->uwb_dev.dev.class = &uwb_rc_class;
rc->uwb_dev.dev.release = uwb_rc_sys_release;
uwb_rc_neh_create(rc);
@@ -110,10 +113,15 @@ EXPORT_SYMBOL_GPL(uwb_rc_init);
struct uwb_rc *uwb_rc_alloc(void)
{
struct uwb_rc *rc;
+ int result;
+
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
if (rc == NULL)
return NULL;
- uwb_rc_init(rc);
+ if (uwb_rc_init(rc)) {
+ kfree(rc);
+ rc = NULL;
+ }
return rc;
}
EXPORT_SYMBOL_GPL(uwb_rc_alloc);
--- a/drivers/uwb/uwb-internal.h
+++ b/drivers/uwb/uwb-internal.h
@@ -37,7 +37,7 @@
struct uwb_beca_e;
/* General device API */
-extern void uwb_dev_init(struct uwb_dev *uwb_dev);
+extern int uwb_dev_init(struct uwb_dev *uwb_dev);
extern int __uwb_dev_offair(struct uwb_dev *, struct uwb_rc *);
extern int uwb_dev_add(struct uwb_dev *uwb_dev, struct device *parent_dev,
struct uwb_rc *parent_rc);
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -454,7 +454,9 @@ struct hd_struct *add_partition(struct g
else
dev_set_name(pdev, "%s%d", dname, partno);
- device_initialize(pdev);
+ err = device_initialize(pdev);
+ if (err)
+ goto out_free_stats;
pdev->class = &block_class;
pdev->type = &part_type;
pdev->parent = ddev;
--- a/include/linux/uwb.h
+++ b/include/linux/uwb.h
@@ -590,7 +590,7 @@ static inline unsigned __uwb_dev_addr_as
* This API is used (in addition to the general API) to implement UWB
* Radio Controllers.
*/
-void uwb_rc_init(struct uwb_rc *);
+int uwb_rc_init(struct uwb_rc *);
int uwb_rc_add(struct uwb_rc *, struct device *dev, void *rc_priv);
void uwb_rc_rm(struct uwb_rc *);
void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t);
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -140,6 +140,7 @@ static void del_conn(struct work_struct
void hci_conn_init_sysfs(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
+ int retval;
BT_DBG("conn %p", conn);
@@ -147,7 +148,7 @@ void hci_conn_init_sysfs(struct hci_conn
conn->dev.class = bt_class;
conn->dev.parent = &hdev->dev;
- device_initialize(&conn->dev);
+ retval = device_initialize(&conn->dev);
INIT_WORK(&conn->work_add, add_conn);
INIT_WORK(&conn->work_del, del_conn);
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -323,6 +323,7 @@ struct wiphy *wiphy_new(const struct cfg
struct cfg80211_registered_device *rdev;
int alloc_size;
+ int retval;
WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));