From patchwork Tue Jul 11 16:29:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brandt X-Patchwork-Id: 9835095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90E5C60363 for ; Tue, 11 Jul 2017 16:31:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80FD628543 for ; Tue, 11 Jul 2017 16:31:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 759F4205F6; Tue, 11 Jul 2017 16:31:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 100C4205F6 for ; Tue, 11 Jul 2017 16:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933919AbdGKQa5 (ORCPT ); Tue, 11 Jul 2017 12:30:57 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:5827 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932526AbdGKQaz (ORCPT ); Tue, 11 Jul 2017 12:30:55 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie4.idc.renesas.com with ESMTP; 12 Jul 2017 01:30:52 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id F0ED1448C5; Wed, 12 Jul 2017 01:30:52 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.40,347,1496070000"; d="scan'208";a="249681418" Received: from unknown (HELO rtamta01.rta.renesas.com) ([143.103.48.75]) by relmlii1.idc.renesas.com with ESMTP; 12 Jul 2017 01:30:51 +0900 Received: from localhost.localdomain (unknown [143.103.58.232]) by rtamta01.rta.renesas.com (Postfix) with ESMTP id A3412252; Tue, 11 Jul 2017 16:30:50 +0000 (UTC) From: Chris Brandt To: Ulf Hansson , Wolfram Sang Cc: Dan Carpenter , Simon Horman , linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Chris Brandt Subject: [PATCH] mmc: tmio-mmc: fix bad pointer math Date: Tue, 11 Jul 2017 09:29:11 -0700 Message-Id: <20170711162911.39114-1-chris.brandt@renesas.com> X-Mailer: git-send-email 2.13.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The existing code gives an incorrect value. The buffer pointer 'buf' was of type unsigned short *, and 'count' was a number in bytes, so the pointer should have been cast before doing any pointer arithmetic. Since we know the code before it is doing as many 4-byte transfers as possible, we just need a pointer to where it left off in the buffer, hence zeroing out the bottom 2 bits of count for out math. Reported-by: Dan Carpenter Fixes: 8185e51f358a: ("mmc: tmio-mmc: add support for 32bit data port") Signed-off-by: Chris Brandt --- drivers/mmc/host/tmio_mmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 77e7b56a9099..5dfc556ccedf 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -428,7 +428,7 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host, if (!(count & 0x3)) return; - buf8 = (u8 *)(buf + (count >> 2)); + buf8 = (u8 *)buf + (count & ~3); count %= 4; if (is_read) {