mmc: block: fix updating ext_csd caches on ioctl call
authorBastian Stender <bst@pengutronix.de>
Thu, 8 Mar 2018 14:08:11 +0000 (15:08 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:22 +0000 (00:30 +0100)
commit2201f59fee9b0f5bc6cf1dc729ab9900de423ced
tree2a6955a8df4d3cf0ca698a7358d3f6c599bb21ec
parent05a45868db488c27ff9f81e0302a35303f574032
mmc: block: fix updating ext_csd caches on ioctl call

commit e74ef2194b41ba5e511fab29fe5ff00e72d2f42a upstream.

PARTITION_CONFIG is cached in mmc_card->ext_csd.part_config and the
currently active partition in mmc_blk_data->part_curr. These caches do
not always reflect changes if the ioctl call modifies the
PARTITION_CONFIG registers, e.g. by changing BOOT_PARTITION_ENABLE.

Write the PARTITION_CONFIG value extracted from the ioctl call to the
cache and update the currently active partition accordingly. This
ensures that the user space cannot change the values behind the
kernel's back. The next call to mmc_blk_part_switch() will operate on
the data set by the ioctl and reflect the changes appropriately.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[bwh: Backported to 3.2:
 - Also add the definition of MMC_EXTRACT_INDEX_FROM_ARG()
 - Adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/mmc/card/block.c