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@xxxxxxxxxxxxxx> --- 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; + while (!list_empty(&packed->list)) { prq = list_entry_rq(packed->list.next); if (idx == i) { -- 2.3.7 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html