mmc: queue: Improve error handling during allocation of bounce buffers
authorBhuvanesh Surachari <bhuvanesh_surachari@mentor.com>
Mon, 1 Dec 2014 07:23:02 +0000 (02:23 -0500)
committerUlf Hansson <ulf.hansson@linaro.org>
Fri, 5 Dec 2014 09:33:17 +0000 (10:33 +0100)
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>
drivers/mmc/card/queue.c

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