mmc: sdio: deploy error handling instead of triggering BUG_ON
authorShawn Lin <shawn.lin@rock-chips.com>
Fri, 26 Aug 2016 00:49:56 +0000 (08:49 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 26 Sep 2016 19:31:15 +0000 (21:31 +0200)
commit923dff87373708801f501cbe8993df98a91b566e
treed25d01c5fa12812979ecfb35a6158b1617446e46
parent96e52daa508bf349582e41911da66461b54dcc12
mmc: sdio: deploy error handling instead of triggering BUG_ON

When using mmc_io_rw_extended, it's intent to avoid null
pointer of card and invalid func number. But actually it
didn't prevent that as the seg_size already use the card.
Currently the wrapper function sdio_io_rw_ext_helper already
use card before calling mmc_io_rw_extended, so we should move
this check to there. As to the func number, it was token from
'(ocr & 0x70000000) >> 28' which should be enough to guarantee
that it won't be larger than 7. But we should prevent the
caller like wifi drivers modify this value. So let's move this
check into sdio_io_rw_ext_helper either.

Also we remove the BUG_ON for mmc_send_io_op_cond since all
possible paths calling this function are protected by checking
the arguments in advance. After deploying these changes, we
could not see any panic within SDIO API even if func drivers
abuse the SDIO func APIs.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/sdio_io.c
drivers/mmc/core/sdio_ops.c