From patchwork Thu Mar 17 11:19:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Gautier X-Patchwork-Id: 12783899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBF44C433F5 for ; Thu, 17 Mar 2022 11:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9H8cE8fjBrYbkswVG1Uzd1QPhA/DGHti++7DSyaQnTs=; b=IPGUDUdwkAToIp Q8l4gqgld7TGNGHwh3sLFhoLVdkgr4Zfu71KPytP1i5+aAE1apJEJToj4DuNafiFCYrzajP+ph6T1 8jrwIQIXPuOoxpYpM7+R8tdlKrCfqrF7achylzGc3ZOw0L2/ZQa8ehQ2PhvjPWIJxZz42gEAtO/lu wlyLL14Lzh1wLCKpwy6ARuqygBxCrhD4cMFYiGRjbWBD4+6TjLEQ34BEmhPSj348R94MyAU5Dg5d5 SJCuGifkjgcQ9fps7mDYPV9pEVHG2s7f6amj79FG3VqB6l16rlyceYI3yNPc9WUKG/Sbcg/OiAk6b Kg9ysElCMs+UDfFyUMnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUoAq-00FoAa-FL; Thu, 17 Mar 2022 11:20:08 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUoAc-00Fo75-QN for linux-arm-kernel@lists.infradead.org; Thu, 17 Mar 2022 11:19:56 +0000 Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22H8Jqq9004865; Thu, 17 Mar 2022 12:19:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=w2nyXAE0VDUlZL+SxQ7bmp0Dq7df9ir8gPXG9f7twWQ=; b=TkIkfs+tnPeaI6+HQTT8aFqjVZzN77AwFWUzIG8b8CTv/Xmj560Csk0WpnX+pgMPGj1a 8lNTfEEv2f1yLer4D/Jw/xoLJK+t3vdjW3WojE+FurC8vQPufOwqls5kipFBqWtTna9c UZgGwzbccWotZstVPN2bXlZsdC3zbDaGsjGhKW7lIZRgYUip2VFbeiAAc171IUv6mGT1 EgTMC5oLbgeFmPLpQPRicI7hxqRCcB3g/jNovQ8it9ZBVWrsJnrHbdUL5uGdaDKsnRLm 7dGJnwyglwkupM68XyoX54vRf7v4jTqZnxi0JLUjfMgMLnGmWzNtW6AS6EbIJfF2zyRv PQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3et63jc89j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Mar 2022 12:19:51 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4C733100034; Thu, 17 Mar 2022 12:19:51 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4536E217B69; Thu, 17 Mar 2022 12:19:51 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Thu, 17 Mar 2022 12:19:51 +0100 From: Yann Gautier To: Ulf Hansson CC: Christophe Kerello , Ludovic Barre , Maxime Coquelin , Alexandre Torgue , Philipp Zabel , Linus Walleij , , , , , Yann Gautier Subject: [PATCH 1/2] mmc: mmci: stm32: correctly check all elements of sg list Date: Thu, 17 Mar 2022 12:19:43 +0100 Message-ID: <20220317111944.116148-2-yann.gautier@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220317111944.116148-1-yann.gautier@foss.st.com> References: <20220317111944.116148-1-yann.gautier@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-17_04,2022-03-15_01,2022-02-23_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220317_041955_536881_B301D3BE X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use sg and not data->sg when checking sg list elements. Else only the first element alignment is checked. The last element should be checked the same way, for_each_sg already set sg to sg_next(sg). Fixes: 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant") Signed-off-by: Yann Gautier --- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c index 9c13f2c31365..4566d7fc9055 100644 --- a/drivers/mmc/host/mmci_stm32_sdmmc.c +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c @@ -62,8 +62,8 @@ static int sdmmc_idma_validate_data(struct mmci_host *host, * excepted the last element which has no constraint on idmasize */ for_each_sg(data->sg, sg, data->sg_len - 1, i) { - if (!IS_ALIGNED(data->sg->offset, sizeof(u32)) || - !IS_ALIGNED(data->sg->length, SDMMC_IDMA_BURST)) { + if (!IS_ALIGNED(sg->offset, sizeof(u32)) || + !IS_ALIGNED(sg->length, SDMMC_IDMA_BURST)) { dev_err(mmc_dev(host->mmc), "unaligned scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length); @@ -71,7 +71,7 @@ static int sdmmc_idma_validate_data(struct mmci_host *host, } } - if (!IS_ALIGNED(data->sg->offset, sizeof(u32))) { + if (!IS_ALIGNED(sg->offset, sizeof(u32))) { dev_err(mmc_dev(host->mmc), "unaligned last scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length);