Skip to contentSkip to conversation

mmc: core: Add open-ended Ext memory addressing

bug report Dan Carpenter 2 participants 2 messages Oct 9, 2024 – Oct 10, 2024 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

Hello Avri Altman,

Commit 737d220bb2be ("mmc: core: Add open-ended Ext memory addressing") from Oct 6, 2024 (linux-next), leads to the following Smatch static checker warning:

	drivers/mmc/core/core.c:358 mmc_start_request()
	error: we previously assumed 'mrq->cmd' could be null (see line 339)

drivers/mmc/core/core.c
335 int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) 336 {
337 int err;
338
339 if (mrq->cmd && mrq->cmd->has_ext_addr)

                    ^^^^^^^^

The patch addes this NULL check

340 mmc_send_ext_addr(host, mrq->cmd->ext_addr);
341
342 init_completion(&mrq->cmd_completion);
343
344 mmc_retune_hold(host);
345
346 if (mmc_card_removed(host->card))
347 return -ENOMEDIUM;
348
349 mmc_mrq_pr_debug(host, mrq, false);
350
351 WARN_ON(!host->claimed);
352
353 err = mmc_mrq_prep(host, mrq);
354 if (err)
355 return err;
356
357 led_trigger_event(host->led, LED_FULL);

   358          __mmc_start_request(host, mrq);
                                          ^^^

But if mrq->cmd is NULL the __mmc_start_request() function will crash. Hopefully, we can just remove the NULL check.

359
360 return 0;
361 }

regards,
dan carpenter

#1 lore raw
Quoted 10 lines

Commit 737d220bb2be ("mmc: core: Add open-ended Ext memory addressing") from Oct 6, 2024 (linux-next), leads to the following Smatch static checker warning:

        drivers/mmc/core/core.c:358 mmc_start_request()
        error: we previously assumed 'mrq->cmd' could be null (see line 339)

drivers/mmc/core/core.c
335 int mmc_start_request(struct mmc_host *host, struct mmc_request
*mrq)

Quoted 6 lines
   336  {
   337          int err;
   338
   339          if (mrq->cmd && mrq->cmd->has_ext_addr)
                    ^^^^^^^^

The patch addes this NULL check

Thanks for reporting.
Will remove it as part of a larger cleanup series.

Thanks,
Avri

Quoted 30 lines
   340                  mmc_send_ext_addr(host, mrq->cmd->ext_addr);
   341
   342          init_completion(&mrq->cmd_completion);
   343
   344          mmc_retune_hold(host);
   345
   346          if (mmc_card_removed(host->card))
   347                  return -ENOMEDIUM;
   348
   349          mmc_mrq_pr_debug(host, mrq, false);
   350
   351          WARN_ON(!host->claimed);
   352
   353          err = mmc_mrq_prep(host, mrq);
   354          if (err)
   355                  return err;
   356
   357          led_trigger_event(host->led, LED_FULL);
   358          __mmc_start_request(host, mrq);
                                          ^^^ But if mrq->cmd is NULL the

__mmc_start_request() function will crash.
Hopefully, we can just remove the NULL check.

   359
   360          return 0;
   361  }

regards,
dan carpenter