All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mmc: toshsd: move dereference below check for NULL
@ 2014-11-15 18:56 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-11-15 18:56 UTC (permalink / raw)
  To: Chris Ball, Ondrej Zary; +Cc: Ulf Hansson, linux-mmc, kernel-janitors

We check for NULL pointers after dereferencing so it's too late.  Oddly
enough, Smatch misses this code but complains about the caller passing
NULL pointers to this function:

	drivers/mmc/host/toshsd.c:389 toshsd_irq()
	error: we previously assumed 'host->cmd' could be null (see line 349)

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/mmc/host/toshsd.c b/drivers/mmc/host/toshsd.c
index edb06d6..4666262 100644
--- a/drivers/mmc/host/toshsd.c
+++ b/drivers/mmc/host/toshsd.c
@@ -206,14 +206,14 @@ static irqreturn_t toshsd_thread_irq(int irq, void *dev_id)
 static void toshsd_cmd_irq(struct toshsd_host *host)
 {
 	struct mmc_command *cmd = host->cmd;
-	u8 *buf = (u8 *) cmd->resp;
+	u8 *buf;
 	u16 data;
 
 	if (!host->cmd) {
 		dev_warn(&host->pdev->dev, "Spurious CMD irq\n");
 		return;
 	}
-
+	buf = (u8 *)cmd->resp;
 	host->cmd = NULL;
 
 	if (cmd->flags & MMC_RSP_PRESENT && cmd->flags & MMC_RSP_136) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] mmc: toshsd: move dereference below check for NULL
@ 2014-11-15 18:56 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-11-15 18:56 UTC (permalink / raw)
  To: Chris Ball, Ondrej Zary; +Cc: Ulf Hansson, linux-mmc, kernel-janitors

We check for NULL pointers after dereferencing so it's too late.  Oddly
enough, Smatch misses this code but complains about the caller passing
NULL pointers to this function:

	drivers/mmc/host/toshsd.c:389 toshsd_irq()
	error: we previously assumed 'host->cmd' could be null (see line 349)

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/mmc/host/toshsd.c b/drivers/mmc/host/toshsd.c
index edb06d6..4666262 100644
--- a/drivers/mmc/host/toshsd.c
+++ b/drivers/mmc/host/toshsd.c
@@ -206,14 +206,14 @@ static irqreturn_t toshsd_thread_irq(int irq, void *dev_id)
 static void toshsd_cmd_irq(struct toshsd_host *host)
 {
 	struct mmc_command *cmd = host->cmd;
-	u8 *buf = (u8 *) cmd->resp;
+	u8 *buf;
 	u16 data;
 
 	if (!host->cmd) {
 		dev_warn(&host->pdev->dev, "Spurious CMD irq\n");
 		return;
 	}
-
+	buf = (u8 *)cmd->resp;
 	host->cmd = NULL;
 
 	if (cmd->flags & MMC_RSP_PRESENT && cmd->flags & MMC_RSP_136) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] mmc: toshsd: move dereference below check for NULL
  2014-11-15 18:56 ` Dan Carpenter
@ 2014-11-19 10:51   ` Ulf Hansson
  -1 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2014-11-19 10:51 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Chris Ball, Ondrej Zary, linux-mmc, kernel-janitors

On 15 November 2014 19:56, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We check for NULL pointers after dereferencing so it's too late.  Oddly
> enough, Smatch misses this code but complains about the caller passing
> NULL pointers to this function:
>
>         drivers/mmc/host/toshsd.c:389 toshsd_irq()
>         error: we previously assumed 'host->cmd' could be null (see line 349)
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks! Applied for next.

Kind regards
Uffe

>
> diff --git a/drivers/mmc/host/toshsd.c b/drivers/mmc/host/toshsd.c
> index edb06d6..4666262 100644
> --- a/drivers/mmc/host/toshsd.c
> +++ b/drivers/mmc/host/toshsd.c
> @@ -206,14 +206,14 @@ static irqreturn_t toshsd_thread_irq(int irq, void *dev_id)
>  static void toshsd_cmd_irq(struct toshsd_host *host)
>  {
>         struct mmc_command *cmd = host->cmd;
> -       u8 *buf = (u8 *) cmd->resp;
> +       u8 *buf;
>         u16 data;
>
>         if (!host->cmd) {
>                 dev_warn(&host->pdev->dev, "Spurious CMD irq\n");
>                 return;
>         }
> -
> +       buf = (u8 *)cmd->resp;
>         host->cmd = NULL;
>
>         if (cmd->flags & MMC_RSP_PRESENT && cmd->flags & MMC_RSP_136) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] mmc: toshsd: move dereference below check for NULL
@ 2014-11-19 10:51   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2014-11-19 10:51 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Chris Ball, Ondrej Zary, linux-mmc, kernel-janitors

On 15 November 2014 19:56, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We check for NULL pointers after dereferencing so it's too late.  Oddly
> enough, Smatch misses this code but complains about the caller passing
> NULL pointers to this function:
>
>         drivers/mmc/host/toshsd.c:389 toshsd_irq()
>         error: we previously assumed 'host->cmd' could be null (see line 349)
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks! Applied for next.

Kind regards
Uffe

>
> diff --git a/drivers/mmc/host/toshsd.c b/drivers/mmc/host/toshsd.c
> index edb06d6..4666262 100644
> --- a/drivers/mmc/host/toshsd.c
> +++ b/drivers/mmc/host/toshsd.c
> @@ -206,14 +206,14 @@ static irqreturn_t toshsd_thread_irq(int irq, void *dev_id)
>  static void toshsd_cmd_irq(struct toshsd_host *host)
>  {
>         struct mmc_command *cmd = host->cmd;
> -       u8 *buf = (u8 *) cmd->resp;
> +       u8 *buf;
>         u16 data;
>
>         if (!host->cmd) {
>                 dev_warn(&host->pdev->dev, "Spurious CMD irq\n");
>                 return;
>         }
> -
> +       buf = (u8 *)cmd->resp;
>         host->cmd = NULL;
>
>         if (cmd->flags & MMC_RSP_PRESENT && cmd->flags & MMC_RSP_136) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-19 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15 18:56 [patch] mmc: toshsd: move dereference below check for NULL Dan Carpenter
2014-11-15 18:56 ` Dan Carpenter
2014-11-19 10:51 ` Ulf Hansson
2014-11-19 10:51   ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.