diff options
author | Julia Lawall <julia@diku.dk> | 2009-12-14 21:01:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:34 -0500 |
commit | 3423d80af67a94a641cc3297ec8c0869aa7f197c (patch) | |
tree | 79c40fb875c0145598e05d3e7dfb93fd208a3f3b /drivers/mmc | |
parent | 4ec64960653c91fa86373d06a079eb7a63deb21f (diff) |
drivers/mmc: Move dereference after NULL test
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>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/s3cmci.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index ec15f1bbf8b9..b4db401874e0 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -820,7 +820,7 @@ fail_request: | |||
820 | static void finalize_request(struct s3cmci_host *host) | 820 | static void finalize_request(struct s3cmci_host *host) |
821 | { | 821 | { |
822 | struct mmc_request *mrq = host->mrq; | 822 | struct mmc_request *mrq = host->mrq; |
823 | struct mmc_command *cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd; | 823 | struct mmc_command *cmd; |
824 | int debug_as_failure = 0; | 824 | int debug_as_failure = 0; |
825 | 825 | ||
826 | if (host->complete_what != COMPLETION_FINALIZE) | 826 | if (host->complete_what != COMPLETION_FINALIZE) |
@@ -828,6 +828,7 @@ static void finalize_request(struct s3cmci_host *host) | |||
828 | 828 | ||
829 | if (!mrq) | 829 | if (!mrq) |
830 | return; | 830 | return; |
831 | cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd; | ||
831 | 832 | ||
832 | if (cmd->data && (cmd->error == 0) && | 833 | if (cmd->data && (cmd->error == 0) && |
833 | (cmd->data->error == 0)) { | 834 | (cmd->data->error == 0)) { |