summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMahammad Ismayilzada <mahammad.ismayilzada@freescale.com>2015-06-23 22:04:07 (GMT)
committerHaiying Wang <Haiying.wang@freescale.com>2015-11-02 19:58:17 (GMT)
commit3ac31aa3d0c611fbbcc07dcac7da7574f9b692bc (patch)
treebea40456c18ff753442875d260777e8a66d1b96a
parente11b65b593068fcfb9f838cbffe7df69ea471c12 (diff)
downloadlinux-fsl-qoriq-3ac31aa3d0c611fbbcc07dcac7da7574f9b692bc.tar.xz
fsl-dce: Handle memory allocation failures
Check for memory allocation failures to protect from null pointer dereferencing Signed-off-by: Mahammad Ismayilzada <mahammad.ismayilzada@freescale.com>
-rw-r--r--drivers/staging/fsl_dce/tests/performance_simple/dce_perf_simple.c8
-rw-r--r--drivers/staging/fsl_dce/tests/performance_simple/dce_sf_perf_simple.c13
2 files changed, 17 insertions, 4 deletions
diff --git a/drivers/staging/fsl_dce/tests/performance_simple/dce_perf_simple.c b/drivers/staging/fsl_dce/tests/performance_simple/dce_perf_simple.c
index d91c42c..388f420 100644
--- a/drivers/staging/fsl_dce/tests/performance_simple/dce_perf_simple.c
+++ b/drivers/staging/fsl_dce/tests/performance_simple/dce_perf_simple.c
@@ -816,8 +816,10 @@ static int do_operation(void)
pr_err("fsl_dce_chunk_deflate_params failed %d\n", ret);
def_process_req = kzalloc(sizeof(*def_process_req), GFP_KERNEL);
- if (!def_process_req)
+ if (!def_process_req) {
pr_err("Line %d\n", __LINE__);
+ return -ENOMEM;
+ }
init_completion(&def_process_req->cb_done);
@@ -951,8 +953,10 @@ done:
if (fsl_dce_get_status(def_process_req->output_fd.status) != STREAM_END)
goto skip_output_copy;
test_data->out_data = vmalloc(def_process_req->dce_cf[0].length);
- if (!test_data->out_data)
+ if (!test_data->out_data) {
pr_err("Unable to allocate output data\n");
+ return -ENOMEM;
+ }
test_data->out_data_len = def_process_req->dce_cf[0].length;
if (!bman_output) {
diff --git a/drivers/staging/fsl_dce/tests/performance_simple/dce_sf_perf_simple.c b/drivers/staging/fsl_dce/tests/performance_simple/dce_sf_perf_simple.c
index d0e5fe0..10154b1 100644
--- a/drivers/staging/fsl_dce/tests/performance_simple/dce_sf_perf_simple.c
+++ b/drivers/staging/fsl_dce/tests/performance_simple/dce_sf_perf_simple.c
@@ -926,8 +926,10 @@ static int do_operation(void)
for (i = 0; i < chunk_count; i++) {
def_process_req = kzalloc(sizeof(*def_process_req), GFP_KERNEL);
- if (!def_process_req)
+ if (!def_process_req) {
pr_err("Line %d\n", __LINE__);
+ return -ENOMEM;
+ }
def_process_req->extra_data_size = i;
@@ -1065,6 +1067,11 @@ try_again:
}
i++;
}
+
+ if (!def_process_req) {
+ pr_err("Line %d\n", __LINE__);
+ return -EINVAL;
+ }
/* wait for last request to be processed */
wait_for_completion(&def_process_req->cb_done);
end_time = mfatb();
@@ -1092,8 +1099,10 @@ done:
pr_info("Total output required %d\n", total_out);
test_data->out_data_len = total_out;
test_data->out_data = vmalloc(total_out);
- if (!test_data->out_data)
+ if (!test_data->out_data) {
pr_err("vmalloc FAILED\n");
+ return -ENOMEM;
+ }
p_out = test_data->out_data;
/* copy output */