From patchwork Wed May 4 05:31:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9009641 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9EC16BF29F for ; Wed, 4 May 2016 05:31:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D560620377 for ; Wed, 4 May 2016 05:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29E8C20374 for ; Wed, 4 May 2016 05:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751052AbcEDFbh (ORCPT ); Wed, 4 May 2016 01:31:37 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:32841 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbcEDFbg (ORCPT ); Wed, 4 May 2016 01:31:36 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O6N01DKU0OMW770@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Wed, 04 May 2016 14:31:34 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.112]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 61.FC.04903.63989275; Wed, 4 May 2016 14:31:34 +0900 (KST) X-AuditID: cbfee690-f79056d000001327-f2-572989369a2a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id A9.AC.06657.53989275; Wed, 4 May 2016 14:31:33 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6N001DF0OLY450@mmp1.samsung.com>; Wed, 04 May 2016 14:31:33 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, adrian.hunter@intel.com, shawn.lin@rock-chips.com, Jaehoon Chung Subject: [PATCH] mmc: queue: allocate the scatterlist with a correct value Date: Wed, 04 May 2016 14:31:31 +0900 Message-id: <1462339891-10477-1-git-send-email-jh80.chung@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKLMWRmVeSWpSXmKPExsWyRsSkQNesUzPc4OMBZouTT9awWdz41cZq ceR/P6PFnSfrWS2Orw13YPVYvOclk8eda3vYPP7O2s/i0bdlFaPH501yAaxRXDYpqTmZZalF +nYJXBn7pj5iLFjJUdF2ULCB8TdbFyMnh4SAicTqjTeZIWwxiQv31gPFuTiEBFYwSrw9vJUR pujm3LmsXYzsQImljBK5ECU/GCWuTrzOBFLCJqAjsf3bcTBbREBW4uefC2DzmQXKJfZtOAhm Cwt4Sdw8dwSshkVAVWLivRVg43kF3CR2/boPdY+cxMljk1lBFkgIvGaTmPl5IyNEg4DEt8mH WLoYOYASshKbDkDdLClxcMUNlgmMggsYGVYxiqYWJBcUJ6UXmegVJ+YWl+al6yXn525iBIbm 6X/PJuxgvHfA+hCjAAejEg/vBE/NcCHWxLLiytxDjKZAGyYyS4km5wMjIK8k3tDYzMjC1MTU 2Mjc0kxJnPe11M9gIYH0xJLU7NTUgtSi+KLSnNTiQ4xMHJxSDYw5h4M97AqnGv488/uD0LPN 538L7FzCc5s5dsmsC4n6V96fMLwVcDrjhleJ2Lq+//d413X9muLWp7k6YCUDv/zetZt8Fv/f cFX4R8gmpd9fU3dFb1ivZX38yh+Jkz1LmJQPrP3OvuDTbs47S05dqtl9S23qac2St55C0p+/ v+tnEZ/idffhm/lnZyixFGckGmoxFxUnAgDuZsJlSAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42I5/e+xgK5pp2a4welT1hYnn6xhs7jxq43V 4sj/fkaLO0/Ws1ocXxvuwOqxeM9LJo871/awefydtZ/Fo2/LKkaPz5vkAlijGhhtMlITU1KL FFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4CWKymUJeaUAoUCEouL lfTtME0IDXHTtYBpjND1DQmC6zEyQAMJaxgz9k19xFiwkqOi7aBgA+Nvti5GTg4JAROJm3Pn skLYYhIX7q0HirNzCAksZZTI7WLkArJ+MEpcnXidCaSETUBHYvu342C2iICsxM8/F8DGMAuU S+zbcBDMFhbwkrh57ghYDYuAqsTEeysYQWxeATeJXb/uQ62Vkzh5bDLrBEbuBYwMqxglUguS C4qT0nMN81LL9YoTc4tL89L1kvNzNzGCw/+Z1A7Gg7vcDzEKcDAq8fC+8NYMF2JNLCuuzD3E KMHBrCTCK9QOFOJNSaysSi3Kjy8qzUktPsRoCnTARGYp0eR8YGzmlcQbGpuYGVkamRtaGBmb K4nzPv6/LkxIID2xJDU7NbUgtQimj4mDU6qBceXL64U/9z1VjpQoDmtpO118Q/bZizVMDbmi EV4vbHLCHhxWbfQyX1IReviG+Y7Md75BOyPfThNe/tY8eqK7qWm3twhLQ4pMdujJvZccb79s uPD6ivnnOcsDLbt3HmLv+PbEXumN24Q+vtwJf8Lumy3x2hD8ZU7C/Dy37yca3SZeOcb3KfJm ohJLcUaioRZzUXEiAD9eSYyVAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If host->max is lower than PAGE_CACHE_SIZE, it should allocate the scatterlist with incorrect size. To prevent illegal behavior, fixed the scatterlist size for mmc_alloc_sg(). Signed-off-by: Jaehoon Chung --- drivers/mmc/card/queue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 6f4323c..0353f99 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -276,12 +276,14 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, blk_queue_max_segments(mq->queue, host->max_segs); blk_queue_max_segment_size(mq->queue, host->max_seg_size); - mqrq_cur->sg = mmc_alloc_sg(host->max_segs, &ret); + mqrq_cur->sg = + mmc_alloc_sg(mq->queue->limits.max_segments, &ret); if (ret) goto cleanup_queue; - mqrq_prev->sg = mmc_alloc_sg(host->max_segs, &ret); + mqrq_prev->sg = + mmc_alloc_sg(mq->queue->limits.max_segments, &ret); if (ret) goto cleanup_queue; }