From: Julia Lawall Date: Tue, 15 Dec 2009 02:01:20 +0000 (-0800) Subject: drivers/mmc: Move dereference after NULL test X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3423d80af67a94a641cc3297ec8c0869aa7f197c;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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/): // @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // Signed-off-by: Julia Lawall Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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: 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) @@ -828,6 +828,7 @@ static void finalize_request(struct s3cmci_host *host) if (!mrq) return; + cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd; if (cmd->data && (cmd->error == 0) && (cmd->data->error == 0)) {