From patchwork Wed Sep 4 14:40:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 1157789 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="KZ1TRwhZ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46NmgV5XmSz9sPT for ; Thu, 5 Sep 2019 00:39:50 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5E81CC21D72; Wed, 4 Sep 2019 14:39:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6DDB9C21C2F; Wed, 4 Sep 2019 14:39:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E06EDC21C2F; Wed, 4 Sep 2019 14:39:40 +0000 (UTC) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lists.denx.de (Postfix) with ESMTPS id 3FC88C21C29 for ; Wed, 4 Sep 2019 14:39:40 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x84Edas0018070; Wed, 4 Sep 2019 09:39:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1567607976; bh=2HT1URQetFSHQyboN9QoZgsGalj2gGZVFe2P0z35mz0=; h=From:To:CC:Subject:Date; b=KZ1TRwhZ9GnS7TIW0/doGRGSp+uG0ht7+dwdrxMZlT/dsw7KMhzGLTsJzwO9/7oIu J3iBUhJ9wXLtjKwaeOlyeWl2yrijudQMrc07DNV91u0ncitElXsP5tWQHHRgc6NqTx ez++vkFqKmKcKT1jndCqaPJXn29h3sz0h/uqrbg0= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x84Edaqq043782 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Sep 2019 09:39:36 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 4 Sep 2019 09:39:36 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 4 Sep 2019 09:39:36 -0500 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x84EdYFR091655; Wed, 4 Sep 2019 09:39:35 -0500 From: Faiz Abbas To: Date: Wed, 4 Sep 2019 20:10:12 +0530 Message-ID: <20190904144012.26829-1-faiz_abbas@ti.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: trini@konsulko.com, Alexey.Brodkin@synopsys.com Subject: [U-Boot] [PATCH] disk: part_dos: Allocate at least one block size for mbr X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The blk_dread() following the mbr allocation reads one block from the device. This will lead to overflow if block size is greater than the size of legacy_mbr. Fix this by allocating at least one block size. Signed-off-by: Faiz Abbas Acked-by: Alexey Brodkin --- disk/part_dos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index aae9d95906..8ddc13b50c 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -93,7 +93,8 @@ static int test_block_type(unsigned char *buffer) static int part_test_dos(struct blk_desc *dev_desc) { #ifndef CONFIG_SPL_BUILD - ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, 1); + ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, + DIV_ROUND_UP(dev_desc->blksz, sizeof(legacy_mbr))); if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) return -1;