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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch incorporates null pointer check associated with memory allocation
for omap_dm_timer_plat_info using kzalloc()

Tested on OMAP4430 SDP.

Signed-off-by: Tarun Kanti Debbarma <tarun.kanti@xxxxxx>
--- 
 arch/arm/mach-omap2/dmtimers.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/dmtimers.c b/arch/arm/mach-omap2/dmtimers.c
index 772be63..a7e9ac5 100644
--- a/arch/arm/mach-omap2/dmtimers.c
+++ b/arch/arm/mach-omap2/dmtimers.c
@@ -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;
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux