diff mbox

[PATCHv2] omap:dmtimer:no null check for kzalloc

Message ID 1278952205-2580-1-git-send-email-tarun.kanti@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tarun Kanti DebBarma July 12, 2010, 4:30 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/dmtimers.c b/arch/arm/mach-omap2/dmtimers.c
index 772be63..1540627 100644
--- a/arch/arm/mach-omap2/dmtimers.c
+++ b/arch/arm/mach-omap2/dmtimers.c
@@ -192,7 +192,7 @@  void __init omap2_dm_timer_setup_clksrc(void)
 	is_initialized = 1;
 }
 
-void __init omap2_dm_timer_early_init(void)
+int __init omap2_dm_timer_early_init(void)
 {
 	int i = 0;
 
@@ -219,7 +219,7 @@  void __init omap2_dm_timer_early_init(void)
 				break;
 			default:
 				/* Error should never enter here */
-				return;
+				return -EINVAL;
 			}
 
 			pdata->io_base = ioremap(base, SZ_8K);
@@ -248,7 +248,12 @@  void __init omap2_dm_timer_early_init(void)
 
 			pdata = kzalloc(sizeof(struct omap_dm_timer_plat_info),
 					GFP_KERNEL);
-
+			if (!pdata) {
+				pr_err("%s:"
+				"No memory for omap_dm_timer_plat_info\n",
+				__func__);
+				return -ENOMEM;
+			}
 			pdata->omap_dm_clk_enable = omap2_dm_timer_enable;
 			pdata->omap_dm_clk_disable = omap2_dm_timer_disable;
 			pdata->omap_dm_set_source_clk = omap2_dm_timer_set_clk;
@@ -271,7 +276,7 @@  void __init omap2_dm_timer_early_init(void)
 	omap2_dm_timer_setup_clksrc();
 	early_platform_driver_register_all("earlytimer");
 	early_platform_driver_probe("earlytimer", NO_EARLY_TIMERS, 0);
-	return;
+	return 0;
 }
 
 int __init omap2_dm_timer_init(void)
@@ -346,6 +351,12 @@  int __init omap2_dm_timer_init(void)
 
 			pdata = kzalloc(sizeof(struct omap_dm_timer_plat_info),
 					GFP_KERNEL);
+			if (!pdata) {
+				pr_err("%s:"
+				"No memory for omap_dm_timer_plat_info\n",
+				__func__);
+				return -ENOMEM;
+			}
 			pdata->omap_dm_clk_enable = omap2_dm_timer_enable;
 			pdata->omap_dm_clk_disable = omap2_dm_timer_disable;
 			pdata->omap_dm_set_source_clk = omap2_dm_timer_set_clk;
@@ -397,7 +408,12 @@  fail:
 				break;
 			pdata = kzalloc(sizeof(struct omap_dm_timer_plat_info),
 					GFP_KERNEL);
-
+			if (!pdata) {
+				pr_err("%s:"
+				"No memory for omap_dm_timer_plat_info\n",
+				__func__);
+				return -ENOMEM;
+			}
 			pdata->omap_dm_clk_enable = omap2_dm_timer_enable;
 			pdata->omap_dm_clk_disable = omap2_dm_timer_disable;
 			pdata->omap_dm_set_source_clk = omap2_dm_timer_set_clk;
diff --git a/arch/arm/mach-omap2/dmtimers.h b/arch/arm/mach-omap2/dmtimers.h
index 2309e4a..afb2d36 100644
--- a/arch/arm/mach-omap2/dmtimers.h
+++ b/arch/arm/mach-omap2/dmtimers.h
@@ -52,6 +52,6 @@ 
 #define OMAP44XX_GPTIMER11_BASE         0x48088000
 #define OMAP44XX_GPTIMER12_BASE         0x4a320000
 
-void __init omap2_dm_timer_early_init(void);
+int __init omap2_dm_timer_early_init(void);
 
 #endif