mmc: queue: Improve error handling during allocation of bounce buffers

Allocation of previous bounce buffer in mmc_init_queue when the current
bounce buffer allocation fails was leading to a crash later in
__blk_segment_map_sg. Error handling is improved by allocating previous
bounce buffer only if the current bounce buffer allocation succeeds.

Signed-off-by: Bhuvanesh Surachari <bhuvanesh_surachari@mentor.com>
Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Bhuvanesh Surachari 2014-12-01 02:23:02 -05:00 committed by Ulf Hansson
parent 9d65cb88e5
commit fdb409f636
1 changed files with 9 additions and 7 deletions

View File

@ -232,13 +232,15 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
if (!mqrq_cur->bounce_buf) { if (!mqrq_cur->bounce_buf) {
pr_warn("%s: unable to allocate bounce cur buffer\n", pr_warn("%s: unable to allocate bounce cur buffer\n",
mmc_card_name(card)); mmc_card_name(card));
} } else {
mqrq_prev->bounce_buf = kmalloc(bouncesz, GFP_KERNEL); mqrq_prev->bounce_buf =
if (!mqrq_prev->bounce_buf) { kmalloc(bouncesz, GFP_KERNEL);
pr_warn("%s: unable to allocate bounce prev buffer\n", if (!mqrq_prev->bounce_buf) {
mmc_card_name(card)); pr_warn("%s: unable to allocate bounce prev buffer\n",
kfree(mqrq_cur->bounce_buf); mmc_card_name(card));
mqrq_cur->bounce_buf = NULL; kfree(mqrq_cur->bounce_buf);
mqrq_cur->bounce_buf = NULL;
}
} }
} }