diff mbox

mmc: block: get idx after the check of packed

Message ID 1471753379-814-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:22 a.m. UTC
We should not use packed command before we verify
it's valid. So let's move the assignment of idx
after the check.

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

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

Comments

Ulf Hansson Aug. 23, 2016, 10:28 a.m. UTC | #1
On 21 August 2016 at 06:22, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> We should not use packed command before we verify
> it's valid. So let's move the assignment of idx
> after the check.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
>  drivers/mmc/card/block.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 48a5dd7..11d3046 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1883,11 +1883,13 @@ static int mmc_blk_end_packed_req(struct mmc_queue_req *mq_rq)
>  {
>         struct request *prq;
>         struct mmc_packed *packed = mq_rq->packed;
> -       int idx = packed->idx_failure, i = 0;
> +       int idx, i = 0;
>         int ret = 0;
>
>         BUG_ON(!packed);
>
> +       idx = packed->idx_failure;
> +

Instead of changing this, may I suggest we try to implement better
error handling - if needed.

I don't think a BUG_ON() is actually what should be used here.

>         while (!list_empty(&packed->list)) {
>                 prq = list_entry_rq(packed->list.next);
>                 if (idx == i) {
> --
> 2.3.7
>
>

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
--
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/card/block.c b/drivers/mmc/card/block.c
index 48a5dd7..11d3046 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1883,11 +1883,13 @@  static int mmc_blk_end_packed_req(struct mmc_queue_req *mq_rq)
 {
 	struct request *prq;
 	struct mmc_packed *packed = mq_rq->packed;
-	int idx = packed->idx_failure, i = 0;
+	int idx, i = 0;
 	int ret = 0;
 
 	BUG_ON(!packed);
 
+	idx = packed->idx_failure;
+
 	while (!list_empty(&packed->list)) {
 		prq = list_entry_rq(packed->list.next);
 		if (idx == i) {