summaryrefslogtreecommitdiffstats
path: root/drivers/net/cs8900.c
diff options
context:
space:
mode:
authorKrzysztof Halasa <khc@pm.waw.pl>2011-01-06 16:23:01 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-01-07 10:21:22 +0100
commitc5baa0edc4a70c2f44cb7422e2b47ab5c96570ed (patch)
treed45c280198754e96276f6a633a206233504790b3 /drivers/net/cs8900.c
parentc99d28ca568a6e0d713c42bfbb9cd5310588d857 (diff)
downloadbarebox-c5baa0edc4a70c2f44cb7422e2b47ab5c96570ed.tar.gz
barebox-c5baa0edc4a70c2f44cb7422e2b47ab5c96570ed.tar.xz
Fix error handling with malloc, memalign etc. Introduce xmemalign().
The idea is to panic() when there is no memory available for normal operation. Exception: code which can consume arbitrary amount of RAM (example: files allocated in ramfs) must report error instead of panic(). This patch also fixes code which didn't check for NULL from malloc() etc. Usage: malloc(), memalign() return NULL when out of RAM. xmalloc(), xmemalign() always return non-NULL or panic(). Signed-off-by: Krzysztof HaƂasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/cs8900.c')
-rw-r--r--drivers/net/cs8900.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 8120877680..187c0fb425 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -440,14 +440,14 @@ static int cs8900_probe(struct device_d *dev)
debug("cs8900_init()\n");
- priv = (struct cs8900_priv *)malloc(sizeof(*priv));
+ priv = (struct cs8900_priv *)xmalloc(sizeof(*priv));
priv->regs = (u16 *)dev->map_base;
if (cs8900_check_id(priv)) {
free(priv);
return -1;
}
- edev = (struct eth_device *)malloc(sizeof(struct eth_device));
+ edev = (struct eth_device *)xmalloc(sizeof(struct eth_device));
dev->type_data = edev;
edev->priv = priv;