From 63e6ea10ec5b2de7a3fb233d29299e10212e5b42 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 1 Oct 2020 20:42:35 +0200 Subject: [PATCH] Revert "mmc: core: Fix size overflow for mmc partitions" This reverts commit a21260928bd30bab09c7406b72e79415b2f34fcc which is commit f3d7c2292d104519195fdb11192daec13229c219 upstream. It breaks the API and eMMC partitions are not created by users in Android. Bug: 161946584 Signed-off-by: Greg Kroah-Hartman Change-Id: I92366299c847c89d3e652868abd455cabff8ea3e --- drivers/mmc/core/mmc.c | 9 +++++---- include/linux/mmc/card.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 24223cb150d4..b975d6d0116f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -297,7 +297,7 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) } } -static void mmc_part_add(struct mmc_card *card, u64 size, +static void mmc_part_add(struct mmc_card *card, unsigned int size, unsigned int part_cfg, char *name, int idx, bool ro, int area_type) { @@ -313,7 +313,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) { int idx; u8 hc_erase_grp_sz, hc_wp_grp_sz; - u64 part_size; + unsigned int part_size; /* * General purpose partition feature support -- @@ -343,7 +343,8 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) (ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 1] << 8) + ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3]; - part_size *= (hc_erase_grp_sz * hc_wp_grp_sz); + part_size *= (size_t)(hc_erase_grp_sz * + hc_wp_grp_sz); mmc_part_add(card, part_size << 19, EXT_CSD_PART_CONFIG_ACC_GP0 + idx, "gp%d", idx, false, @@ -361,7 +362,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) { int err = 0, idx; - u64 part_size; + unsigned int part_size; struct device_node *np; bool broken_hpi = false; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index cf3780a6ccc4..e459b38ef33c 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -226,7 +226,7 @@ struct mmc_queue_req; * MMC Physical partitions */ struct mmc_part { - u64 size; /* partition size (in bytes) */ + unsigned int size; /* partition size (in bytes) */ unsigned int part_cfg; /* partition type */ char name[MAX_MMC_PART_NAME_LEN]; bool force_ro; /* to make boot parts RO by default */