Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdb409f6 authored by Bhuvanesh Surachari's avatar Bhuvanesh Surachari Committed by Ulf Hansson
Browse files

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: default avatarBhuvanesh Surachari <bhuvanesh_surachari@mentor.com>
Signed-off-by: default avatarHarish Jenny K N <harish_kandiga@mentor.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 9d65cb88
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -232,8 +232,9 @@ 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 =
						kmalloc(bouncesz, GFP_KERNEL);
				if (!mqrq_prev->bounce_buf) {
				if (!mqrq_prev->bounce_buf) {
					pr_warn("%s: unable to allocate bounce prev buffer\n",
					pr_warn("%s: unable to allocate bounce prev buffer\n",
						mmc_card_name(card));
						mmc_card_name(card));
@@ -241,6 +242,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
					mqrq_cur->bounce_buf = NULL;
					mqrq_cur->bounce_buf = NULL;
				}
				}
			}
			}
		}


		if (mqrq_cur->bounce_buf && mqrq_prev->bounce_buf) {
		if (mqrq_cur->bounce_buf && mqrq_prev->bounce_buf) {
			blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY);
			blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY);