From patchwork Thu Jul 5 06:49:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10508249 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 3BC4660116 for ; Thu, 5 Jul 2018 06:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24E0F28DF2 for ; Thu, 5 Jul 2018 06:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17F3628E66; Thu, 5 Jul 2018 06:59:43 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEC1128DF2 for ; Thu, 5 Jul 2018 06:59:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 343876B0271; Thu, 5 Jul 2018 02:59:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F29C6B0272; Thu, 5 Jul 2018 02:59:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E4186B0273; Thu, 5 Jul 2018 02:59:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id D31BD6B0271 for ; Thu, 5 Jul 2018 02:59:39 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id v10-v6so4271559pfm.11 for ; Wed, 04 Jul 2018 23:59:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=bbciGCD7g5D2j3+1ToCmKRdt7ItBTTKK0praTDXMxwc=; b=UG1le7mLqv+lsw538s/2BoehEJ+V5ctj+c1D6j/ewTEv4Ocrv3ZjLoKfVmgd7mxNv3 z6RoQuFYV5LzBHdVvWQ7OgYqG9eGZern+e+rc/Yr/I4sC8OYFyjJd4RFcH6Cvq40HrYm 8HsSOHJhqtsPyxxmHVDmvLb5Rm/d57ckZWDeidiF8j4Blipoz/CT99cXWVc313pXPiKv +RBIiJGGvIOfSPQVK/srgWpwPt6Qfn6mKBS72Kv8PG5ujG9TqvVybnQa90O20KO2dYdm bOl3oTYjc6pgCtfcUwl/pe/luUm9/clFRgaosAyKTTbgLWy4Ni0g/4e+gK0ZP1hrLPEA 95KA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E10PFrqzrZCgmbfWvIRW5qNot87LarCXx/d28Ec4GonmHPG6EcL CbUdxOCt9rYE9Z8AJGNgYRi8hvG+7TbV6xPSlRF2/58lE6M3Yelf2Q9+onmpX5f/1JU6v29K0sS b0XcrM+ez2g/DokgJinzJ89gzffIZ3oM/baFyc5Rpv8TBzcyp61DlmwHmQ60CUpWCoQ== X-Received: by 2002:a62:f587:: with SMTP id b7-v6mr5143365pfm.158.1530773979546; Wed, 04 Jul 2018 23:59:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc8lxxwF4UIz+ize9zwyS45cHCSCLn8IRIhuoUZb0L0a7E9h6mXQPJJ83KYJsUw68yEAwMs X-Received: by 2002:a62:f587:: with SMTP id b7-v6mr5143318pfm.158.1530773978696; Wed, 04 Jul 2018 23:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530773978; cv=none; d=google.com; s=arc-20160816; b=ABjQ0bqmZcsvKD8KECB+PDjEDn0Xdjc/cJy0d28HslmONnkiIBifOU24WAXkC12phJ VRSU88TJyQfGNCrRiBKNenhDziukOWOQ8EQw1fbqfqHOHE6obxW5SLkZI9JMXLZP7AFF xKKAWdJh/5hK9IYpwRbt8jGZg89WZjC5XHDiu3Q//AjH6wz14MaowCEVSZPK3530waD8 WZNpj5uElQt1VDAY/bb99+zTQhjdVBSGBWxTfclMETza77zfY2zkyHXKk14ofCnLb/0I hjTf4wXTwZOPc0CUAZm1sMHo6bCTq//xzntUQ7353+/6mAgZEirdRFni1/3wl3dpUQsk Vahw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=bbciGCD7g5D2j3+1ToCmKRdt7ItBTTKK0praTDXMxwc=; b=z2tBKQrBnS5CSvyKYiCcjQmp5AyWpHZyKmeOr7iJ6IGXLmYlZXq+ua4WZ+saHf6GhT U3+dxZAuo+UdKmTr9uXj1LwGZE4L2zV04jc9NDVFE7TrX+iA0i6xOYE/dB+hO4aWkMM0 rTnvZb/l5E3yf7sFPqUEpr90ydRdw/JS60ucIyQTVAVFOIN/IYkvOAc2u8rY+KVwumZT JyViajNFQKo4PuhfhT0vJLcIc9ij8avpRkxOKote9TWBd+WNywc8hugZU48iWVELegki qnxerM+7uRee9qYpwPUh5jB/B3/gDM62NqShSgg38CO0SJMNM7ZaO0rEdHW2SFH3XEmE OgPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id n8-v6si5154556pgl.101.2018.07.04.23.59.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 23:59:38 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 23:59:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="242767670" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga005.fm.intel.com with ESMTP; 04 Jul 2018 23:59:37 -0700 Subject: [PATCH 07/13] nvdimm/pmem-dax: check the validity of the pointer pfn From: Dan Williams To: akpm@linux-foundation.org Cc: Huaisheng Ye , Jan Kara , vishal.l.verma@intel.com, hch@lst.de, linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 04 Jul 2018 23:49:40 -0700 Message-ID: <153077338038.40830.8894996377094953603.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye direct_access needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- tools/testing/nvdimm/pmem-dax.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596ad601b..d4cb5281b30e 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -33,7 +33,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); @@ -41,7 +42,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, } *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the