From patchwork Thu Jul 5 06:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10508243 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 51ED6603D7 for ; Thu, 5 Jul 2018 06:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E4D328DF2 for ; Thu, 5 Jul 2018 06:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E5728E49; Thu, 5 Jul 2018 06:59:37 +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 C350C28DF2 for ; Thu, 5 Jul 2018 06:59:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EFC66B026F; Thu, 5 Jul 2018 02:59:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 678056B0270; Thu, 5 Jul 2018 02:59:34 -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 565F16B0271; Thu, 5 Jul 2018 02:59:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 16EE56B026F for ; Thu, 5 Jul 2018 02:59:34 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id b5-v6so1417579ple.20 for ; Wed, 04 Jul 2018 23:59:34 -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=CoSC/3Fi8L6h7NQhmevDzSKfrrXp6p2PHCeZ3XAO6BY=; b=nZKPLSh1bi8OpzPo/FR/K2IY/YjWLPecekzGGOuKOHDP3S4a5x8c1ZbY/bhnk24oHQ onH5r3Ri4fOtJTBwca5+w/UctA2CjJ111QCUO8pJMOJhGDUZu7gCL4asM2enh+R4OdED f9mzI8RCQca0R7c3n5nXUZVmM4102GAQqFdnvPIy94H4ooqCx7BUm3EHkZcMguvQB/o/ DXxTKwzRYcgkWpRdasmDQLbGcnlcGP0zmYNcM2RrLCwREEussZdAw/V683WPyH+p51ta QJBkbV3GfRc3PaKCJRho+wGO2nmbjWr0b6b95+X+kZ5QddLzG/cpXUAYpB2FzQlp9/vm J63A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 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: APt69E3Er1AotymbQS0o4sdKSjL0gYxM86YhKJ3uBF57611FhteQweFo gRzjvs4AFIfpqI8veWePT8YvAsK2hgSoQiwev1jjl4/YN6kNE3y2YO+iUH9ql4/jMDvprx2Csea kupstDQCFuxTP5DfQzQOf+TrS+HzYFHmBxnq5VIfFNVsXEwV2uWw6uhuoUseqbnTzZg== X-Received: by 2002:a65:5284:: with SMTP id y4-v6mr4236396pgp.283.1530773973780; Wed, 04 Jul 2018 23:59:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe02EIIBGjfsFrYursVoezZb3vROwuN01BNfw9QTl9QIAkgPEOYyXpGhDy73RN+t4lTuizM X-Received: by 2002:a65:5284:: with SMTP id y4-v6mr4236369pgp.283.1530773973148; Wed, 04 Jul 2018 23:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530773973; cv=none; d=google.com; s=arc-20160816; b=Gl1+6Kb2tRYKxJwfzeFU7Zsk+uaRN1CmULoCSGsQAVa6AFb7oO8yY/QTyDtuBukENc YvVEoB6zCUAy59FfrykE+3UTnTlkj3wADz1YiD0QAlmOm0x5L/7+18PnLx+ni/Ce4RWZ IcWgOegpWzuiSO712W1vfDYro03rf5KdVzZe/7bF8aoppSf/eMKUfwb0ZUyde53l/lcz EnCkz+8dBK0+8su5WU3Bxyzo4bcIWqFU8SvVwov9na8ltt1c+rHD4jHCqohdCR0Gz9+N mXLMMGtcIy2MRHDeZtvO4ahWNzDqr7e29tDn5DKjk2kE/36+NZu7cScuhzjBj00MzcQY ODyA== 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=CoSC/3Fi8L6h7NQhmevDzSKfrrXp6p2PHCeZ3XAO6BY=; b=kcRTimW/DVcU9GeYWomrAtaRer5DvwoGp4/k8R30WRUAK+XPdaFCz02m3RApEbd/zB wHuGpro/uTxwldHAEekTk+o+i7oHBQrVWfhryppG+2FrFr4g07u66QAQUgEG+8jhcotb pz/BxIfV/wD8HyZufyEEQKrvdsUR6NjfQPF36mi2ViB4UyAZu/sUFWz+8tTjg4wjbCJN klhjKRLmsz7ERJX72r8z6gOw4P03R4keYuZuKhivFhLQusAvvPrHHGoDV847asGlu5jJ vz9Ea+I8+x/oVzn8qWzryBpT7gTRijGBLHNhPCNj6GdBIL6nfI2Zj5fM/vVj6l5VE1bV ZMeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id p5-v6si5157595pgl.516.2018.07.04.23.59.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 23:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 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 fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 23:59:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="62403642" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jul 2018 23:59:32 -0700 Subject: [PATCH 06/13] nvdimm/pmem: 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:34 -0700 Message-ID: <153077337481.40830.15235657458024188710.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. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- drivers/nvdimm/pmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index e8ac6f244d2b..c430536320a5 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -228,7 +228,8 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, PFN_PHYS(nr_pages)))) return -EIO; *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