From patchwork Mon May 11 07:34:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 6373601 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 53882BEEE1 for ; Mon, 11 May 2015 07:35:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78C4F2024F for ; Mon, 11 May 2015 07:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2208E20225 for ; Mon, 11 May 2015 07:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbbEKHe7 (ORCPT ); Mon, 11 May 2015 03:34:59 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:46012 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751870AbbEKHe6 (ORCPT ); Mon, 11 May 2015 03:34:58 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 11 May 2015 16:34:57 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 3013D4E64A; Mon, 11 May 2015 16:34:57 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 1F880480A3; Mon, 11 May 2015 16:34:57 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 12976480A6; Mon, 11 May 2015 16:34:57 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id SAJ15016; Mon, 11 May 2015 16:34:57 +0900 X-IronPort-AV: E=Sophos;i="5.13,405,1427727600"; d="scan'208";a="187060136" Received: from mail-hk1lp0122.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.122]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 11 May 2015 16:34:56 +0900 Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; Received: from morimoto-PC.renesas.com (211.11.155.132) by SINPR06MB314.apcprd06.prod.outlook.com (10.141.115.145) with Microsoft SMTP Server (TLS) id 15.1.160.19; Mon, 11 May 2015 07:34:53 +0000 Message-ID: <87twvj36x2.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/2 v2] mmc: cast u8 to unsigned long long to avoid unexpected error User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Ulf Hansson CC: , , , , Jaehoon Chung , Chris Ball , Seungwon Jeon , =?ISO-8859-1?Q?=22Gr=E9gory_Soutad?= =?ISO-8859-1?Q?=E9=22?= , , In-Reply-To: <87vbfz36yh.wl%kuninori.morimoto.gx@renesas.com> References: <87wq1n5bht.wl%kuninori.morimoto.gx@renesas.com> <87vbfz36yh.wl%kuninori.morimoto.gx@renesas.com> Date: Mon, 11 May 2015 07:34:53 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: KAWPR01CA0031.jpnprd01.prod.outlook.com (25.165.48.141) To SINPR06MB314.apcprd06.prod.outlook.com (10.141.115.145) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB314; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:SINPR06MB314; BCL:0; PCL:0; RULEID:; SRVR:SINPR06MB314; X-Forefront-PRVS: 05739BA1B5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(36756003)(4001350100001)(15975445007)(77096005)(87976001)(93886004)(77156002)(5001960100002)(110136002)(50466002)(46406003)(66066001)(2950100001)(19580395003)(122386002)(46102003)(189998001)(50986999)(54356999)(19580405001)(76176999)(62966003)(40100003)(86362001)(42186005)(47776003)(33646002)(229853001)(92566002)(53416004); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB314; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2015 07:34:53.6252 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SINPR06MB314 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Kuninori Morimoto card->ext_csd.enhanced_area_offset is defined as "unsigned long long", and, ext_csd[] is defined as u8. unsigned long long data might have strange data if first bit of ext_csd[] was 1. this patch cast it to (unsigned long long) Special thanks to coverity ex) u8 data8; u64 data64; data8 = 0x80; data64 = (data8 << 24); // 0xffffffff80000000 data64 = (((unsigned long long)data8) << 24); // 0x80000000; Signed-off-by: Kuninori Morimoto --- v1 -> v2 - Tidyjp log comment drivers/mmc/core/mmc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f36c76f..2be4073 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -266,8 +266,10 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) * calculate the enhanced data area offset, in bytes */ card->ext_csd.enhanced_area_offset = - (ext_csd[139] << 24) + (ext_csd[138] << 16) + - (ext_csd[137] << 8) + ext_csd[136]; + (((unsigned long long)ext_csd[139]) << 24) + + (((unsigned long long)ext_csd[138]) << 16) + + (((unsigned long long)ext_csd[137]) << 8) + + (((unsigned long long)ext_csd[136])); if (mmc_card_blockaddr(card)) card->ext_csd.enhanced_area_offset <<= 9; /*