Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4330394pxb; Tue, 26 Jan 2021 19:52:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfRht5FZkfeMgTZJ45qI4BrtmGCWPf5bB0ZlfkA63enn7FJwBmn6XAfRnbKJKuBotHA+k8 X-Received: by 2002:a17:906:4442:: with SMTP id i2mr3479378ejp.41.1611719572146; Tue, 26 Jan 2021 19:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611719572; cv=none; d=google.com; s=arc-20160816; b=A/UEvKcbedYT+/UDWv1bDlj7Hw5OfoJFQScANL305GMIkniE5aoG53j9BQ3zuxlnDD 9yhl3WTKJDWHK/fZqyJsPbhUn/URbkXijcXr85OakdH4ZSgQNhbQ+GFB1A5cBejY1psF j08u+TmmVxteGnZcal6w+Ml8bYHapQdJGugiUgsy7zDEB+8GZiInftSxNSoigliEuPPT tgB0ijbH1EzRqEh/2RnC4GF2arnu3DkwTn5KbK36rGZhlwTXLX1VR9++G6qyy2ZSatLF EGmEI2fa/mNs1/Fk6gMT3rZO0HTIy57KiQ5w3XPiJLcn4YxIcok1rROyGpzFTpBMmBw7 7VAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YmOWTMyDzmXyV34BzcLEqx+RCzuU+hmr/4OBCJSWSro=; b=DZvPvj8YUacGS/7UIhb0H+TP++nO0LY7N0G8jMQ/Cl/D1zxSV6D/uQtVmuIMe4ZSj6 UiZjAXg6hhvmeAD20ku4dUzZF4WPUE2ecB5O3Z5w19+MClbk+V9ejMNJ416o8J0TPfY2 l4xfsAaBiVJMBhoBjGUeQpPUNerGbtxLXYV3DtvqbtEaoqJBFfJ+66IALZsB+G6dFfoZ W6In0UlmL2IXNCUjTuIFsiIgR8FJ7zZrpSvnfZaipJIZ7LXG16QoqWKK494gIZrB5OY5 clkMS2I3AVDAa7quTI25TRgQs43xhgYLSs3Wq3vj/Fn4aNQ63ZXRxTQVGiPphwhKNL0g 7MlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bXVicpHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si290091eja.552.2021.01.26.19.52.27; Tue, 26 Jan 2021 19:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bXVicpHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390107AbhAZI35 (ORCPT + 99 others); Tue, 26 Jan 2021 03:29:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:59198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727743AbhAYSmy (ORCPT ); Mon, 25 Jan 2021 13:42:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A7C6B22DD6; Mon, 25 Jan 2021 18:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611600094; bh=Cu0z/aHc4Cf7CcsswqVfHjZGhn6IQNokWBtr9lkD57A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXVicpHzmZEB1f6aactGAsDF0fb0LBknXdBDVK/DCCe2sgNz5vQ47+c3JiEo82Vhq Tpo2mHLf0U5y7TLfTpvtzi9myKdpGyn1zO2OyaSR30Zlsdi4OobA6AWqp3tLFGx/Rh qJS/+6hJihSZg9KD9TMOi3kYqV4OR/0Bt+ga6USE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Collingbourne , Damien Le Moal , Adrian Hunter , Ulf Hansson Subject: [PATCH 4.19 06/58] mmc: core: dont initialize block size from ext_csd if not present Date: Mon, 25 Jan 2021 19:39:07 +0100 Message-Id: <20210125183156.976227629@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210125183156.702907356@linuxfoundation.org> References: <20210125183156.702907356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Collingbourne commit b503087445ce7e45fabdee87ca9e460d5b5b5168 upstream. If extended CSD was not available, the eMMC driver would incorrectly set the block size to 0, as the data_sector_size field of ext_csd was never initialized. This issue was exposed by commit 817046ecddbc ("block: Align max_hw_sectors to logical blocksize") which caused max_sectors and max_hw_sectors to be set to 0 after setting the block size to 0, resulting in a kernel panic in bio_split when attempting to read from the device. Fix it by only reading the block size from ext_csd if it is available. Fixes: a5075eb94837 ("mmc: block: Allow disabling 512B sector size emulation") Signed-off-by: Peter Collingbourne Reviewed-by: Damien Le Moal Link: https://linux-review.googlesource.com/id/If244d178da4d86b52034459438fec295b02d6e60 Acked-by: Adrian Hunter Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210114201405.2934886-1-pcc@google.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/queue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -364,8 +364,10 @@ static void mmc_setup_queue(struct mmc_q min(host->max_blk_count, host->max_req_size / 512)); blk_queue_max_segments(mq->queue, host->max_segs); - if (mmc_card_mmc(card)) + if (mmc_card_mmc(card) && card->ext_csd.data_sector_size) { block_size = card->ext_csd.data_sector_size; + WARN_ON(block_size != 512 && block_size != 4096); + } blk_queue_logical_block_size(mq->queue, block_size); blk_queue_max_segment_size(mq->queue,