linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Cavium MMC driver smatch fixes
@ 2017-04-13 12:10 Jan Glauber
  2017-04-13 12:10 ` [PATCH 1/2] mmc: cavium: Remove redundant pointer check Jan Glauber
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Glauber @ 2017-04-13 12:10 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: David Daney, Steven J . Hill, linux-mmc, linux-kernel, Jan Glauber

Hi Ulf,

here are two cosmetical changes for the reported smatch errors.

Jan Glauber (2):
  mmc: cavium: Remove redundant pointer check
  mmc: cavium: Check pointer before de-reference

 drivers/mmc/host/cavium.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.9.0.rc0.21.g7777322

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

* [PATCH 1/2] mmc: cavium: Remove redundant pointer check
  2017-04-13 12:10 [PATCH 0/2] Cavium MMC driver smatch fixes Jan Glauber
@ 2017-04-13 12:10 ` Jan Glauber
  2017-04-13 12:10 ` [PATCH 2/2] mmc: cavium: Check pointer before de-reference Jan Glauber
  2017-04-18 19:15 ` [PATCH 0/2] Cavium MMC driver smatch fixes Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Glauber @ 2017-04-13 12:10 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: David Daney, Steven J . Hill, linux-mmc, linux-kernel, Jan Glauber

Remove redundant mmc->card check reported by smatch:

drivers/mmc/host/cavium.c:694 cvm_mmc_dma_request()
	warn: variable dereferenced before check 'mmc->card' (see line 675)

Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
 drivers/mmc/host/cavium.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index d842b69..ddf902c 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -691,7 +691,7 @@ static void cvm_mmc_dma_request(struct mmc_host *mmc,
 	 * bit mask to check for CRC errors and timeouts only.
 	 * Otherwise, use the default power reset value.
 	 */
-	if (mmc->card && mmc_card_sd(mmc->card))
+	if (mmc_card_sd(mmc->card))
 		writeq(0x00b00000ull, host->base + MIO_EMM_STS_MASK(host));
 	else
 		writeq(0xe4390080ull, host->base + MIO_EMM_STS_MASK(host));
-- 
2.9.0.rc0.21.g7777322

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

* [PATCH 2/2] mmc: cavium: Check pointer before de-reference
  2017-04-13 12:10 [PATCH 0/2] Cavium MMC driver smatch fixes Jan Glauber
  2017-04-13 12:10 ` [PATCH 1/2] mmc: cavium: Remove redundant pointer check Jan Glauber
@ 2017-04-13 12:10 ` Jan Glauber
  2017-04-18 19:15 ` [PATCH 0/2] Cavium MMC driver smatch fixes Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Glauber @ 2017-04-13 12:10 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: David Daney, Steven J . Hill, linux-mmc, linux-kernel, Jan Glauber

Add a pointer check to prevent this smatch warning:

drivers/mmc/host/cavium.c:803 cvm_mmc_request()
	error: we previously assumed 'cmd->data' could be null (see line 782)

This is a theoretical fix because MMC_CMD_ADTC seems to imply
that cmd->data is not null. Nevertheless checking cmd->data
before using it improves readability.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
 drivers/mmc/host/cavium.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index ddf902c..d89c2eb 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -799,7 +799,7 @@ static void cvm_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		  FIELD_PREP(MIO_EMM_CMD_IDX, cmd->opcode) |
 		  FIELD_PREP(MIO_EMM_CMD_ARG, cmd->arg);
 	set_bus_id(&emm_cmd, slot->bus_id);
-	if (mmc_cmd_type(cmd) == MMC_CMD_ADTC)
+	if (cmd->data && mmc_cmd_type(cmd) == MMC_CMD_ADTC)
 		emm_cmd |= FIELD_PREP(MIO_EMM_CMD_OFFSET,
 				64 - ((cmd->data->blocks * cmd->data->blksz) / 8));
 
-- 
2.9.0.rc0.21.g7777322

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

* Re: [PATCH 0/2] Cavium MMC driver smatch fixes
  2017-04-13 12:10 [PATCH 0/2] Cavium MMC driver smatch fixes Jan Glauber
  2017-04-13 12:10 ` [PATCH 1/2] mmc: cavium: Remove redundant pointer check Jan Glauber
  2017-04-13 12:10 ` [PATCH 2/2] mmc: cavium: Check pointer before de-reference Jan Glauber
@ 2017-04-18 19:15 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2017-04-18 19:15 UTC (permalink / raw)
  To: Jan Glauber; +Cc: David Daney, Steven J . Hill, linux-mmc, linux-kernel

On 13 April 2017 at 14:10, Jan Glauber <jglauber@cavium.com> wrote:
> Hi Ulf,
>
> here are two cosmetical changes for the reported smatch errors.
>
> Jan Glauber (2):
>   mmc: cavium: Remove redundant pointer check
>   mmc: cavium: Check pointer before de-reference
>
>  drivers/mmc/host/cavium.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> --
> 2.9.0.rc0.21.g7777322
>

Thanks, applied for next!

Kind regards
Uffe

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

end of thread, other threads:[~2017-04-18 19:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13 12:10 [PATCH 0/2] Cavium MMC driver smatch fixes Jan Glauber
2017-04-13 12:10 ` [PATCH 1/2] mmc: cavium: Remove redundant pointer check Jan Glauber
2017-04-13 12:10 ` [PATCH 2/2] mmc: cavium: Check pointer before de-reference Jan Glauber
2017-04-18 19:15 ` [PATCH 0/2] Cavium MMC driver smatch fixes Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).