powerpc/vio: Use put_device() on device_register failure
authorNishanth Aravamudan <nacc@us.ibm.com>
Wed, 15 Sep 2010 08:05:47 +0000 (08:05 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 13 Oct 2010 05:19:21 +0000 (16:19 +1100)
The kernel doc for device_register (and device_initialize) very clearly
state to call put_device not kfree after calling, even on error.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/vio.c

index fa3469ddaef8d010bca8974765c9c656dfa06635..72db4b0217624c1484b3fd08f4f7d48212e0503b 100644 (file)
@@ -1254,8 +1254,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
        if (device_register(&viodev->dev)) {
                printk(KERN_ERR "%s: failed to register device %s\n",
                                __func__, dev_name(&viodev->dev));
-               /* XXX free TCE table */
-               kfree(viodev);
+               put_device(&viodev->dev);
                return NULL;
        }