summaryrefslogtreecommitdiffstats
path: root/drivers/mca/mca-bus.c
diff options
context:
space:
mode:
authorJeff Garzik2006-10-11 10:22:23 +0200
committerLinus Torvalds2006-10-11 20:14:25 +0200
commit49a6cbe1cd8a72451d9d6ab5b1e163f17c1bbee3 (patch)
tree519d69f7daef24f8258c0ca125e1da7344d3a81d /drivers/mca/mca-bus.c
parent[PATCH] firmware/efivars: handle error (diff)
downloadkernel-qcow2-linux-49a6cbe1cd8a72451d9d6ab5b1e163f17c1bbee3.tar.gz
kernel-qcow2-linux-49a6cbe1cd8a72451d9d6ab5b1e163f17c1bbee3.tar.xz
kernel-qcow2-linux-49a6cbe1cd8a72451d9d6ab5b1e163f17c1bbee3.zip
[PATCH] drivers/mca: handle sysfs errors
Also includes a kmalloc->kzalloc cleanup. Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: James Bottomley <James.Bottomley@steeleye.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/mca/mca-bus.c')
-rw-r--r--drivers/mca/mca-bus.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index 09baa43b2599..da862e4632dd 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -100,6 +100,7 @@ static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL);
int __init mca_register_device(int bus, struct mca_device *mca_dev)
{
struct mca_bus *mca_bus = mca_root_busses[bus];
+ int rc;
mca_dev->dev.parent = &mca_bus->dev;
mca_dev->dev.bus = &mca_bus_type;
@@ -108,13 +109,23 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
mca_dev->dev.dma_mask = &mca_dev->dma_mask;
mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
- if (device_register(&mca_dev->dev))
- return 0;
+ rc = device_register(&mca_dev->dev);
+ if (rc)
+ goto err_out;
- device_create_file(&mca_dev->dev, &dev_attr_id);
- device_create_file(&mca_dev->dev, &dev_attr_pos);
+ rc = device_create_file(&mca_dev->dev, &dev_attr_id);
+ if (rc) goto err_out_devreg;
+ rc = device_create_file(&mca_dev->dev, &dev_attr_pos);
+ if (rc) goto err_out_id;
return 1;
+
+err_out_id:
+ device_remove_file(&mca_dev->dev, &dev_attr_id);
+err_out_devreg:
+ device_unregister(&mca_dev->dev);
+err_out:
+ return 0;
}
/* */
@@ -130,13 +141,16 @@ struct mca_bus * __devinit mca_attach_bus(int bus)
return NULL;
}
- mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL);
+ mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL);
if (!mca_bus)
return NULL;
- memset(mca_bus, 0, sizeof(struct mca_bus));
+
sprintf(mca_bus->dev.bus_id,"mca%d",bus);
sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
- device_register(&mca_bus->dev);
+ if (device_register(&mca_bus->dev)) {
+ kfree(mca_bus);
+ return NULL;
+ }
mca_root_busses[bus] = mca_bus;
span class='column5'>|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | | * | | | | | Documentation: Add minimal Mutt config for using GmailEddie Kovsky2015-11-111-0/+32 | * | | | | | Documentation: Add note on sending files directly with MuttEddie Kovsky2015-11-111-0/+4 | * | | | | | Documentation: dontdiff: remove media from dontdiffWang YanQing2015-11-111-1/+0Star | * | | | | | Documentation/SubmittingPatches: discuss In-Reply-ToChris Metcalf2015-11-111-1/+14 | * | | | | | Remove email address from Documentation/filesystems/overlayfs.txtNeilBrown2015-11-111-1/+2 | * | | | | | can-doc: Add missing semicolon to exampleStefan Tatschner2015-11-111-1/+1 * | | | | | | Merge tag 'devicetree-fixes-for-4.4' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds2015-11-121-0/+0 |\ \ \ \ \ \ \ | * | | | | | | dt-bindings: ak4554: extension should be .txtRaphael Poggi2015-11-111-0/+0 * | | | | | | | Merge tag 'pwm/for-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/...Linus Torvalds2015-11-115-0/+107 |\ \ \ \ \ \ \ \ | * | | | | | | | pwm: pwm-rcar: Revise the device tree binding document about compatibleYoshihiro Shimoda2015-11-101-2/+1Star | * | | | | | | | pwm: sun4i: Add support for PWM controller on sun5i SoCsHans de Goede2015-11-101-0/+2 | * | | | | | | | dt-bindings: pwm: Add MediaTek display PWM bindingsYH Huang2015-10-061-0/+42 | * | | | | | | | Documentation: dt: add Broadcom BCM7038 PWM controller bindingFlorian Fainelli2015-10-061-0/+20 | * | | | | | | | pwm: Add device tree binding document for R-Car PWM TimerYoshihiro Shimoda2015-10-061-0/+27 | * | | | | | | | pwm: Add Berlin PWM controller DT bindingAntoine Ténart2015-10-051-0/+17 | | |_|/ / / / / | |/| | | | | | * | | | | | | | Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/l...Linus Torvalds2015-11-112-2/+23 |\ \ \ \ \ \ \ \ | * \ \ \ \ \ \ \ Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalent...Zhang Rui2015-11-061-2/+9 | |\ \ \ \ \ \ \ \ | | * | | | | | | | dt-bindings: rockchip-thermal: Add the pinctrl states in this documentCaesar Wang2015-11-031-2/+9 | * | | | | | | | | Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalent...Zhang Rui2015-11-031-0/+14 | |\| | | | | | | | | | * | | | | | | | thermal: ti-soc-thermal: add OMAP36xx supportEduardo Valentin2015-09-291-0/+7 | | * | | | | | | | ti-soc-thermal: implement omap3 supportPavel Machek2015-09-291-0/+7 * | | | | | | | | | Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmare...Linus Torvalds2015-11-114-0/+314 |\ \ \ \ \ \ \ \ \ \ | * | | | | | | | | | kbuild: document recursive dependency limitation / resolutionLuis R. Rodriguez2015-10-084-0/+314 | | |_|/ / / / / / / | |/| | | | | | | | * | | | | | | | | | Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netLinus Torvalds2015-11-113-4/+9 |\ \ \ \ \ \ \ \ \ \ | * | | | | | | | | | net: Documentation: Fix default value tcp_limit_output_bytesNiklas Cassel2015-11-091-1/+1 | * | | | | | | | | | bpf: doc: correct arch list for supported eBPF JITYang Shi2015-11-091-3/+3 | * | | | | | | | | | drivers: net: cpsw: Add support for fixed-link PHYMarkus Brunner2015-11-051-0/+5 * | | | | | | | | | | Merge tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/ar...Linus Torvalds2015-11-11