diff mbox

mmc: sdio: get seg_size after the check of card

Message ID 1471753808-1087-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin Aug. 21, 2016, 4:30 a.m. UTC
When using mmc_io_rw_extended. it's intent to avoid
null pointer of card but actually it didn't prevent
it as the seg_size already use the card. So we need
to move this after the check.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/core/sdio_ops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Aug. 23, 2016, 10:30 a.m. UTC | #1
On 21 August 2016 at 06:30, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> When using mmc_io_rw_extended. it's intent to avoid
> null pointer of card but actually it didn't prevent
> it as the seg_size already use the card. So we need
> to move this after the check.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
>  drivers/mmc/core/sdio_ops.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
> index 34f6e80..15a06b8 100644
> --- a/drivers/mmc/core/sdio_ops.c
> +++ b/drivers/mmc/core/sdio_ops.c
> @@ -127,7 +127,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
>         struct scatterlist sg, *sg_ptr;
>         struct sg_table sgtable;
>         unsigned int nents, left_size, i;
> -       unsigned int seg_size = card->host->max_seg_size;
> +       unsigned int seg_size;
>
>         BUG_ON(!card);
>         BUG_ON(fn > 7);

Can we try to remove these BUG_ONs() instead and deploy proper error
handling - if needed.

> @@ -137,6 +137,8 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
>         if (addr & ~0x1FFFF)
>                 return -EINVAL;
>
> +       seg_size = card->host->max_seg_size;
> +
>         mrq.cmd = &cmd;
>         mrq.data = &data;
>
> --
> 2.3.7
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index 34f6e80..15a06b8 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -127,7 +127,7 @@  int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
 	struct scatterlist sg, *sg_ptr;
 	struct sg_table sgtable;
 	unsigned int nents, left_size, i;
-	unsigned int seg_size = card->host->max_seg_size;
+	unsigned int seg_size;
 
 	BUG_ON(!card);
 	BUG_ON(fn > 7);
@@ -137,6 +137,8 @@  int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
 	if (addr & ~0x1FFFF)
 		return -EINVAL;
 
+	seg_size = card->host->max_seg_size;
+
 	mrq.cmd = &cmd;
 	mrq.data = &data;