Skip to content

Commit

Permalink
drivers/mmc: Move dereference after NULL test
Browse files Browse the repository at this point in the history
If the NULL test on mrq is needed, then the derefernce should be after the
NULL test.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Julia Lawall authored and Linus Torvalds committed Dec 15, 2009
1 parent 4ec6496 commit 3423d80
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mmc/host/s3cmci.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,15 @@ static void s3cmci_dma_done_callback(struct s3c2410_dma_chan *dma_ch,
static void finalize_request(struct s3cmci_host *host)
{
struct mmc_request *mrq = host->mrq;
struct mmc_command *cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd;
struct mmc_command *cmd;
int debug_as_failure = 0;

if (host->complete_what != COMPLETION_FINALIZE)
return;

if (!mrq)
return;
cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd;

if (cmd->data && (cmd->error == 0) &&
(cmd->data->error == 0)) {
Expand Down

0 comments on commit 3423d80

Please sign in to comment.