Merge branch 'fix/hda' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[pandora-kernel.git] / arch / powerpc / sysdev / fsl_rio.c
index cbb3bed..71fba88 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/rio_drv.h>
 #include <linux/of_platform.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
@@ -1057,6 +1058,10 @@ int fsl_rio_setup(struct of_device *dev)
                        law_start, law_size);
 
        ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL);
+       if (!ops) {
+               rc = -ENOMEM;
+               goto err_ops;
+       }
        ops->lcread = fsl_local_config_read;
        ops->lcwrite = fsl_local_config_write;
        ops->cread = fsl_rio_config_read;
@@ -1064,6 +1069,10 @@ int fsl_rio_setup(struct of_device *dev)
        ops->dsend = fsl_rio_doorbell_send;
 
        port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
+       if (!port) {
+               rc = -ENOMEM;
+               goto err_port;
+       }
        port->id = 0;
        port->index = 0;
 
@@ -1071,7 +1080,7 @@ int fsl_rio_setup(struct of_device *dev)
        if (!priv) {
                printk(KERN_ERR "Can't alloc memory for 'priv'\n");
                rc = -ENOMEM;
-               goto err;
+               goto err_priv;
        }
 
        INIT_LIST_HEAD(&port->dbells);
@@ -1169,11 +1178,13 @@ int fsl_rio_setup(struct of_device *dev)
 
        return 0;
 err:
-       if (priv)
-               iounmap(priv->regs_win);
-       kfree(ops);
+       iounmap(priv->regs_win);
        kfree(priv);
+err_priv:
        kfree(port);
+err_port:
+       kfree(ops);
+err_ops:
        return rc;
 }