]> git.baikalelectronics.ru Git - uboot.git/commit
mmc: sdhci: fix NULL pointer access when host->ops is not set
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 13 Jan 2017 02:51:51 +0000 (11:51 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 13 Jan 2017 03:17:03 +0000 (12:17 +0900)
commit4f797f95664aa6527b26c953c2b7844b034a354e
treebf6ae953eda31084ad00c89894bc45a2650effff
parent0137e90f432424e4eb7773ad044b7c009e8ba27d
mmc: sdhci: fix NULL pointer access when host->ops is not set

Until recently, sdhci_ops was used only for overriding IO accessors.
(so, host->ops was not set by any drivers except bcm2835_sdhci.c)

Now, we have more optional callbacks, get_cd, set_control_reg, and
set_clock.  However, the code

    if (host->ops->get_cd)
            host->ops->get_cd(host);

... expects host->ops is set for all drivers.

Commit 57d163e7b7e4 ("mmc: pic32_sdhci: move the code to
pic32_sdhci.c") and commit 06fd87a84d1a ("mmc: sdhci: move the
callback function into sdhci_ops") added sdhci_ops for pic32_sdhci.c
and s5p_sdhci.c, but the other drivers still do not (need not) set
host->ops because all callbacks in sdhci_ops are optional.

host->ops must be checked to avoid the system crash caused by NULL
pointer access.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/mmc/sdhci.c