summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Huewe <peterhuewe@gmx.de>2013-02-19 13:07:28 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-11 09:15:32 -0700
commiteb1bd49c50880df667905b4cfb472064f62c05d1 (patch)
treebbac4621c3d1c03046feefb0ab065ef6404e63dc
parentc37aeab62514cd623afa1b952ca86d53dd21a745 (diff)
staging/sep: Check pointers before dereferencing (fix smatch warning)
smatch complains about two dereferenced before check issues: sep_main.c:2898 sep_free_dma_tables_and_dcb() warn: variable dereferenced before check 'dma_ctx' (see line 2885) sep_main.c:2898 sep_free_dma_tables_and_dcb() warn: variable dereferenced before check '*dma_ctx' (see line 2885) -> Move the checks to the top, but keep the semantics. Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/sep/sep_main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index 366d56b9a255..f5b73419eebc 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -2880,6 +2880,8 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
dev_dbg(&sep->pdev->dev, "[PID%d] sep_free_dma_tables_and_dcb\n",
current->pid);
+ if (!dma_ctx || !*dma_ctx) /* nothing to be done here*/
+ return 0;
if (((*dma_ctx)->secure_dma == false) && (isapplet == true)) {
dev_dbg(&sep->pdev->dev, "[PID%d] handling applet\n",
@@ -2895,8 +2897,7 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
* Go over each DCB and see if
* tail pointer must be updated
*/
- for (i = 0; dma_ctx && *dma_ctx &&
- i < (*dma_ctx)->nr_dcb_creat; i++, dcb_table_ptr++) {
+ for (i = 0; i < (*dma_ctx)->nr_dcb_creat; i++, dcb_table_ptr++) {
if (dcb_table_ptr->out_vr_tail_pt) {
pt_hold = (unsigned long)dcb_table_ptr->
out_vr_tail_pt;