• Shawn Lin's avatar
    mmc: sdio: deploy error handling instead of triggering BUG_ON · 923dff87
    Shawn Lin authored
    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: default avatarShawn Lin <shawn.lin@rock-chips.com>
    Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    923dff87
sdio_io.c 18.5 KB