From patchwork Wed Apr 8 07:33:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 6177691 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67B029F2EC for ; Wed, 8 Apr 2015 07:33:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 829AB20306 for ; Wed, 8 Apr 2015 07:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A70A5202E9 for ; Wed, 8 Apr 2015 07:33:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752951AbbDHHd3 (ORCPT ); Wed, 8 Apr 2015 03:33:29 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:34018 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752984AbbDHHd0 (ORCPT ); Wed, 8 Apr 2015 03:33:26 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 08 Apr 2015 16:33:25 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id DF19F4F51D; Wed, 8 Apr 2015 16:33:25 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id D01952806E; Wed, 8 Apr 2015 16:33:25 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id CA9962806D; Wed, 8 Apr 2015 16:33:25 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id SAK04905; Wed, 8 Apr 2015 16:33:25 +0900 X-IronPort-AV: E=Sophos;i="5.11,543,1422889200"; d="scan'208";a="184775879" Received: from mail-hk1lp0118.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.118]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 08 Apr 2015 16:33:24 +0900 Received: from morimoto-PC.renesas.com (211.11.155.132) by SIXPR06MB317.apcprd06.prod.outlook.com (10.141.125.143) with Microsoft SMTP Server (TLS) id 15.1.130.23; Wed, 8 Apr 2015 07:33:21 +0000 Message-ID: <87twwr5b3m.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/2][RFC] 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=E9=22?= , , In-Reply-To: <87vbh75b4x.wl%kuninori.morimoto.gx@renesas.com> References: <87wq1n5bht.wl%kuninori.morimoto.gx@renesas.com> <87vbh75b4x.wl%kuninori.morimoto.gx@renesas.com> Date: Wed, 8 Apr 2015 07:33:21 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: TY1PR01CA0025.jpnprd01.prod.outlook.com (25.161.131.163) To SIXPR06MB317.apcprd06.prod.outlook.com (10.141.125.143) Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB317; X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(87976001)(77156002)(50986999)(93886004)(19580395003)(46406003)(54356999)(83506001)(46102003)(62966003)(53416004)(76176999)(47776003)(110136001)(122386002)(229853001)(66066001)(19580405001)(40100003)(23726002)(42186005)(15975445007)(86362001)(33646002)(77096005)(50466002)(92566002)(36756003)(2950100001)(223183001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB317; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:SIXPR06MB317; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB317; X-Forefront-PRVS: 0540846A1D X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2015 07:33:21.8574 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB317 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) ex) u8 data8; u64 data64; data8 = 0x80; data64 = (data8 << 24); // 0xffffffff80000000 data64 = (((unsigned long long)data8) << 24); // 0x80000000; Reported-by: coverity Signed-off-by: Kuninori Morimoto --- 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 1d41e85..3c663a2 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -265,8 +265,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; /*