From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60082.outbound.protection.outlook.com [40.107.6.82]) by dpdk.org (Postfix) with ESMTP id 4ABC81B10C for ; Wed, 17 Oct 2018 11:05:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kBFrmrhm0VZwwV7kFEBqQmOAAzYGv/nhaFJsnnKbYT4=; b=X3Dg2+ygqy852IZ6HrxMRIhI5EKMIfYGJAdZ5voGppDUKK6lj4toC7FynF9je/riJxVYfpuDDtWzLgmePn86IvkqmMxuJUO7LiG44KxqqWsId0/sDwxmu0CC2v28jT3jI/SUJ3EOnELX2zvw7cjM18rl/guMG0K8xb0Nd+7buaE= Received: from VI1PR04MB4688.eurprd04.prod.outlook.com (20.177.56.80) by VI1PR04MB2110.eurprd04.prod.outlook.com (10.166.43.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.26; Wed, 17 Oct 2018 09:05:57 +0000 Received: from VI1PR04MB4688.eurprd04.prod.outlook.com ([fe80::7988:5f2:be74:bf7a]) by VI1PR04MB4688.eurprd04.prod.outlook.com ([fe80::7988:5f2:be74:bf7a%6]) with mapi id 15.20.1228.032; Wed, 17 Oct 2018 09:05:57 +0000 From: Shreyansh Jain To: "thomas@monjalon.net" CC: "dev@dpdk.org" , Shreyansh Jain Thread-Topic: [PATCH] common/dpaax: fix uninitialized table case Thread-Index: AQHUZficUgaWkVOTKU6kuX+JiIlGzQ== Date: Wed, 17 Oct 2018 09:05:57 +0000 Message-ID: <20181017090517.14530-1-shreyansh.jain@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [14.142.187.166] x-mailer: git-send-email 2.17.1 x-clientproxiedby: PN1PR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::32) To VI1PR04MB4688.eurprd04.prod.outlook.com (2603:10a6:803:71::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR04MB2110; 6:JN2KR2rI2Q+kXdp8rhjEMKjWfFMqeQsw7sj3AWFvBSNC9NEpfmTlGRqKVnSYCs/khPRb6LB1acUF5YNpL4K495m/EpQnpLlOdJu8ueLah6qWOXI+EEABKFJn5IKBkOLDyp5EM0wTz6Vw1wHWqvaK82M04I6NOCLlegCpittbj96fPiXBKkdTAzxB5xk1VOwvtNE2iyDd48OHRfaubZlP02NyiEKeVG/29wiqZcD+WxQXf1iSO6A8Loy1XXfjGY6YnOOoAjTSbkBmGi9zklkh7n58Qp+VhQyySt1rSPx5zgODg5snOhj2IJyQtbh+8e0/wPPwXqlpTbAmY3QCXlp+wcUGjav3JAJMWdLrWkU/Jo57MXNnFGj79OCg/jzttQTbnW2uGrb65q1B97nJu1AszYT2b8P9z35MPlZaVb4Nmba+q1TYbjwn8sJursbc93ufhH5RT/ZLfeJLUHw2Friflw==; 5:v5n/cyljDF5EYsD1/aSQlCOX8YehyqPwaqrWekoP8TvTizb332UpXAMAK9yDG1f7xBBFryVkYpfEvF3mN6KwzWUlK7Kxe+iwuW7iSUSbekeuj5cF96Bupz6Vw3alrRWsrhdoVhUOtAOYNeI82uEjHtGFMfYmKtAfNoU4ZK8lsaQ=; 7:j6dh2taOgCLIBJSXtQdeuu4Iej8w2HNrw0j1dkIFUL7sVqVdANdLWhM/A60h21iPn6FC0MVDUk+H1QwMkWZZ5hZe7EVR6LGCrFfYUEHXgjtg6p48SSBywA8K2PlUmreQH5ofjy4zbN7GLg1OP2EBkbjkbfDfkewrxS6Ge5RDXuX9vTe2d64s4qUi3XIDzqxMiQ6dSGe4HXc7W9krbfWJuT4ooMz4DJItDNQmnc/okLmE6qE1a2iG62d1HFNCxCcB x-ms-office365-filtering-correlation-id: e3fc7edf-5908-4f30-ebac-08d6340fbe68 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB2110; x-ms-traffictypediagnostic: VI1PR04MB2110: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:VI1PR04MB2110; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB2110; x-forefront-prvs: 08286A0BE2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(39860400002)(346002)(376002)(199004)(189003)(106356001)(4326008)(97736004)(105586002)(44832011)(6486002)(6436002)(2616005)(476003)(486006)(478600001)(14454004)(256004)(14444005)(2501003)(78486010)(71190400001)(71200400001)(1076002)(2351001)(66066001)(5250100002)(25786009)(2906002)(6116002)(3846002)(186003)(1857600001)(316002)(53936002)(2900100001)(386003)(26005)(102836004)(52116002)(55236004)(6512007)(5640700003)(99286004)(86362001)(6506007)(6916009)(8676002)(1730700003)(5660300001)(81156014)(305945005)(81166006)(54906003)(7736002)(68736007)(8936002)(50226002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB2110; H:VI1PR04MB4688.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Qdq11b1BaUhEp+dX8nC5qwLzO8uqC95hk4DK8lyQSKC8iZ216ZgHPcVIQGq5F25vV44e4MV72k6jEUdJ8Gb7MHA+BZRF5hIGpdE3HS+2v/HZ/fL7Wn2+M0vo9WdeHdq5/sQH5RoLMnwPq9Q6U0x9+AaDGZyNuw83Y9EzGIiyyiC13dRhvqT3WJRSfMtqnSkzf9HAfvlbB+iJl6F6vpAO/7aG4IC+ovQId0op2Ecrw1ybH4GSLsX3/6/jc9kExk0Q/WDlzCc5rGobo5rxqgY+fYAklOm6uxcjimupshB2r6rhhkZlUmxIqMi2qbsEjLdX8z7Is+vRXdnHJCBA594Bdiyup52A8gZd/OOjCIopOyM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3fc7edf-5908-4f30-ebac-08d6340fbe68 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2018 09:05:57.3105 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB2110 Subject: [dpdk-dev] [PATCH] common/dpaax: fix uninitialized table case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2018 09:05:59 -0000 There is a possibility that either because of missing device tree entry or lack of memory, the PA-VA table might not be available. But, the table being transparent, the callers don't necessary check for its initialization state. This is explicitly done during update and translation call. Fixes: 2f3d633aa593 ("common/dpaax: add library for PA/VA translation table= ") Signed-off-by: Shreyansh Jain --- drivers/common/dpaax/dpaax_iova_table.c | 3 +++ drivers/common/dpaax/dpaax_iova_table.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax= /dpaax_iova_table.c index d54267bb7..075053b1a 100644 --- a/drivers/common/dpaax/dpaax_iova_table.c +++ b/drivers/common/dpaax/dpaax_iova_table.c @@ -272,6 +272,9 @@ dpaax_iova_table_update(phys_addr_t paddr, void *vaddr,= size_t length) uintptr_t align_vaddr; phys_addr_t align_paddr; =20 + if (unlikely(dpaax_iova_table_p =3D=3D NULL)) + return -1; + align_paddr =3D paddr & DPAAX_MEM_SPLIT_MASK; align_vaddr =3D ((uintptr_t)vaddr & DPAAX_MEM_SPLIT_MASK); =20 diff --git a/drivers/common/dpaax/dpaax_iova_table.h b/drivers/common/dpaax= /dpaax_iova_table.h index 1109a362c..138827e7b 100644 --- a/drivers/common/dpaax/dpaax_iova_table.h +++ b/drivers/common/dpaax/dpaax_iova_table.h @@ -74,6 +74,9 @@ dpaax_iova_table_get_va(phys_addr_t paddr) { size_t offset =3D paddr & DPAAX_MEM_SPLIT_MASK_OFF; struct dpaax_iovat_element *entry; =20 + if (unlikely(dpaax_iova_table_p =3D=3D NULL)) + return NULL; + entry =3D dpaax_iova_table_p->entries; =20 do { --=20 2.17.1