Skip to content

Commit

Permalink
staging/sep: Check pointers before dereferencing (fix smatch warning)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Huewe authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent c37aeab commit eb1bd49
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/staging/sep/sep_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
Expand Down

0 comments on commit eb1bd49

Please sign in to comment.