diff options
author | Andrew Goodbody <andrew.goodbody@linaro.org> | 2025-07-29 17:16:17 +0100 |
---|---|---|
committer | Eugen Hristev <eugen.hristev@linaro.org> | 2025-08-13 12:59:36 +0300 |
commit | c1168f99387b40f5e3323ff16c670427c2c8a66e (patch) | |
tree | 674bb210c1e1f952614eacce2285d2bc641b3ef4 | |
parent | 4fb189a58eacd8bac267f2f330b41e7700bcfa12 (diff) |
mmc: gen_atmel_mci: NULL check variable before use
In mci_send_cmd the pointer 'data' is optional so guard its use with a
NULL check to prevent any attempt to dereference it when not provided.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r-- | drivers/mmc/gen_atmel_mci.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c index 62aa6b3cb0b..838b4f4a65a 100644 --- a/drivers/mmc/gen_atmel_mci.c +++ b/drivers/mmc/gen_atmel_mci.c @@ -263,13 +263,15 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) /* Figure out the transfer arguments */ cmdr = mci_encode_cmd(cmd, data, &error_flags); - mci_set_blklen(mci, data->blocksize); + if (data) { + mci_set_blklen(mci, data->blocksize); - /* For multi blocks read/write, set the block register */ - if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK) - || (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)) - writel(data->blocks | MMCI_BF(BLKLEN, data->blocksize), - &mci->blkr); + /* For multi blocks read/write, set the block register */ + if (cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK || + cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK) + writel(data->blocks | MMCI_BF(BLKLEN, data->blocksize), + &mci->blkr); + } /* Send the command */ writel(cmd->cmdarg, &mci->argr); |