gpu: nvgpu: fix Coverity issues

- operands not affecting result (id = 12845)
- logically dead code (id = 12890)
- dereference after null check (id = 12968)
- unsigned compared to 0 (id = 13176)
- resource leak (id = 13338, 18673)
- unused pointer value (id = 13916)

Bug 1703084

Change-Id: I2f401dd93126af27748c53fa1b3a59cb154af36b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/835143
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
This commit is contained in:
Deepak Nibade
2015-11-19 14:26:15 +05:30
committed by Sachin Nikam
parent 836027806d
commit 10f6da09eb
5 changed files with 19 additions and 15 deletions

View File

@@ -1688,17 +1688,14 @@ static int gk20a_channel_add_job(struct channel_gk20a *c,
if (!skip_buffer_refcounting) {
err = gk20a_vm_get_buffers(vm, &mapped_buffers,
&num_mapped_buffers);
if (err) {
gk20a_vm_put(vm);
return err;
}
if (err)
goto err_put_vm;
}
job = kzalloc(sizeof(*job), GFP_KERNEL);
if (!job) {
gk20a_vm_put_buffers(vm, mapped_buffers, num_mapped_buffers);
gk20a_vm_put(vm);
return -ENOMEM;
err = -ENOMEM;
goto err_put_buffers;
}
/* put() is done in gk20a_channel_update() when the job is done */
@@ -1718,10 +1715,20 @@ static int gk20a_channel_add_job(struct channel_gk20a *c,
list_add_tail(&job->list, &c->jobs);
mutex_unlock(&c->jobs_lock);
} else {
return -ETIMEDOUT;
err = -ETIMEDOUT;
goto err_free_job;
}
return 0;
err_free_job:
kfree(job);
err_put_buffers:
gk20a_vm_put_buffers(vm, mapped_buffers, num_mapped_buffers);
err_put_vm:
gk20a_vm_put(vm);
return err;
}
void gk20a_channel_update(struct channel_gk20a *c, int nr_completed)

View File

@@ -1102,7 +1102,7 @@ static int gk20a_pm_enable_clk(struct device *dev)
for (index = 0; index < platform->num_clks; index++) {
int err = 0;
if (platform->clk[index])
clk_prepare_enable(platform->clk[index]);
err = clk_prepare_enable(platform->clk[index]);
if (err)
return -EINVAL;
}
@@ -1623,14 +1623,12 @@ static int gk20a_domain_init(struct of_device_id *matches)
{
int ret = 0;
struct device_node *np;
const struct of_device_id *match;
struct gk20a_domain_data *gk20a_domain;
np = of_find_matching_node(NULL, matches);
if (!np)
return -ENOENT;
match = of_match_node(matches, np);
gk20a_domain = (struct gk20a_domain_data *)kzalloc
(sizeof(struct gk20a_domain_data), GFP_KERNEL);
if (!gk20a_domain)

View File

@@ -314,8 +314,7 @@ void gk20a_scale_init(struct platform_device *pdev)
return;
err_get_freqs:
kfree(g->scale_profile);
g->scale_profile = NULL;
kfree(profile);
}
void gk20a_scale_exit(struct platform_device *pdev)

View File

@@ -105,7 +105,7 @@ static int gk20a_ltc_cbc_ctrl(struct gk20a *g, enum gk20a_cbc_op op,
int err = 0;
struct gr_gk20a *gr = &g->gr;
u32 fbp, slice, ctrl1, val, hw_op = 0;
u32 retry = 200;
int retry = 200;
u32 slices_per_fbp =
ltc_ltcs_ltss_cbc_param_slices_per_fbp_v(
gk20a_readl(g, ltc_ltcs_ltss_cbc_param_r()));

View File

@@ -1735,7 +1735,7 @@ int gk20a_vm_get_compbits_info(struct vm_gk20a *vm,
mapped_buffer = find_mapped_buffer_locked(&vm->mapped_buffers, mapping_gva);
if (!mapped_buffer | !mapped_buffer->user_mapped)
if (!mapped_buffer || !mapped_buffer->user_mapped)
{
mutex_unlock(&vm->update_gmmu_lock);
gk20a_err(d, "%s: bad offset 0x%llx", __func__, mapping_gva);