From c5baa0edc4a70c2f44cb7422e2b47ab5c96570ed Mon Sep 17 00:00:00 2001 From: Krzysztof Halasa Date: Thu, 6 Jan 2011 16:23:01 +0100 Subject: Fix error handling with malloc, memalign etc. Introduce xmemalign(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Sascha Hauer --- drivers/serial/serial_imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/serial/serial_imx.c') diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c index a7562f9db1..984d7f2f51 100644 --- a/drivers/serial/serial_imx.c +++ b/drivers/serial/serial_imx.c @@ -319,7 +319,7 @@ static int imx_serial_probe(struct device_d *dev) struct imx_serial_priv *priv; uint32_t val; - priv = malloc(sizeof(*priv)); + priv = xmalloc(sizeof(*priv)); cdev = &priv->cdev; priv->regs = (void __force __iomem *)dev->map_base; -- cgit v1.2.3