diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c index b4f6a4641..f87e47770 100644 --- a/drivers/gpu/nvgpu/clk/clk_prog.c +++ b/drivers/gpu/nvgpu/clk/clk_prog.c @@ -614,6 +614,8 @@ static u32 clk_prog_construct_1x_master(struct gk20a *g, pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *) kzalloc(vfsize, GFP_KERNEL); + if (!pclkprog->p_vf_entries) + return -ENOMEM; memcpy(pclkprog->p_vf_entries, ptmpprog->p_vf_entries, vfsize); diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index d5c764390..4888ad585 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c @@ -459,6 +459,8 @@ static int nvgpu_gpu_ioctl_wait_for_pause(struct gk20a *g, sm_count = g->gr.gpc_count * g->gr.tpc_count; size = sm_count * sizeof(struct warpstate); w_state = kzalloc(size, GFP_KERNEL); + if (w_state == NULL) + return -ENOMEM; /* Wait for the SMs to reach full stop. This condition is: * 1) All SMs with valid warps must be in the trap handler (SM_IN_TRAP_MODE) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c index df95630bd..05bcd5d29 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c @@ -334,6 +334,8 @@ void gk20a_scale_init(struct device *dev) return; profile = kzalloc(sizeof(*profile), GFP_KERNEL); + if (!profile) + return; profile->dev = dev; profile->dev_stat.busy = false; diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 879349a73..579a8049c 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -3593,6 +3593,9 @@ static int gr_gk20a_init_gr_config(struct gk20a *g, struct gr_gk20a *gr) gr->sm_to_cluster = kzalloc(gr->gpc_count * gr->tpc_count * sizeof(struct sm_info), GFP_KERNEL); + if (!gr->sm_to_cluster) + goto clean_up; + gr->no_of_sm = 0; gk20a_dbg_info("fbps: %d", gr->num_fbps); diff --git a/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c index 16e2e10eb..c32ba9631 100644 --- a/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c @@ -571,8 +571,19 @@ static int ecc_stat_create(struct device *dev, dev_attr_array = kzalloc(sizeof(struct device_attribute) * num_hw_units, GFP_KERNEL); ecc_stat->counters = kzalloc(sizeof(u32) * num_hw_units, GFP_KERNEL); ecc_stat->names = kzalloc(sizeof(char *) * num_hw_units, GFP_KERNEL); + + if (!dev_attr_array || !ecc_stat->counters || !ecc_stat->names) { + error = -ENOMEM; + goto clean_up; + } + for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) { ecc_stat->names[hw_unit] = kzalloc(sizeof(char) * ECC_STAT_NAME_MAX_SIZE, GFP_KERNEL); + if (!ecc_stat->names[hw_unit]) { + hw_unit--; + error = -ENOMEM; + goto clean_up; + } } for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) { @@ -605,6 +616,15 @@ static int ecc_stat_create(struct device *dev, hash_add(ecc_hash_table, &ecc_stat->hash_node, hash_key); + return 0; + +clean_up: + for (;hw_unit >= 0; hw_unit--) { + kfree(ecc_stat->names[hw_unit]); + } + kfree(ecc_stat->names); + kfree(ecc_stat->counters); + kfree(dev_attr_array); return error; }