mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
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>
This commit is contained in:
committed by
Eugen Hristev
parent
4fb189a58e
commit
c1168f9938
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user