Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6724128imm; Tue, 24 Jul 2018 01:47:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfXUnJFlVoOSUunWDwvNs0eCCEHulfUfTiLQBs/GRcg6LOqpgJdgtmHo2+1O7ss8PiUugkJ X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr16346657pla.102.1532422042032; Tue, 24 Jul 2018 01:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532422042; cv=none; d=google.com; s=arc-20160816; b=dAuIlKB9P2ucmp5d73WupzKdS6pqp8yS0IyJGQb29oo0/fuYUdGXyt5R6JmeCRYrhe RiuYIgtGwGCr1t2V2iV4SuK5AUqX+qBEl+lfHa+3VZVrm7slTIBMNxfTmvmtr2oNnhQ3 PVbrIg9SAWF8/VKhbfS7m7SM6t/mBxN3tIbj0Xs+ULrz7bklo50s8zlAD7CaAXIOaDQC vmu3TJHR9KZtdMmM0wMk1yvtZ9izCxPT5V+Ox+39+AdJArNAKzswjjWpWGVElgT4dWaa GQ+a62Cew4puvuV0vzSQOlEQE90yG1nH2QKY3zbKLah9vpMBulSaqi1B1BrjKftIRPGF kT6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:domainkey-signature:arc-authentication-results; bh=0fAlY96xRa4+juirSlEfMmER7m89wKp6wOsvU7czJyQ=; b=TBNbPinIcFq/pYPFmJ+EQzBwBYSD9IyeT0Xye24seMKbEr+FDabcs51hMz0WUAGve3 RjCX72a0LfiARvO5NxQwWL6NBp9k/C+kQomJXYlycDMLuNbz545icWxQCEWEopFI/Fqf NW9SX8DL+wN2sPYyPbUusR7iz2T/MR1Rjo9+EA4gCY0Up5RKoQIYSxDR8kJDYuMb3vPE 3pPdYag2lmL4nvL6gF4fCNURozZYDUvj2xsCAokaZxto3ppvujqCGKMELCJzC/W+j8tY A6n3EADwlRLBw4ON7l+S2Z1PscFKYPG/NPimF2+xEYfLZ6dC/YxnYhiJxjERMIDrLH/9 gVVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12-v6si10400880pgg.532.2018.07.24.01.47.07; Tue, 24 Jul 2018 01:47:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388275AbeGXJve (ORCPT + 99 others); Tue, 24 Jul 2018 05:51:34 -0400 Received: from sender-pp-092.zoho.com ([135.84.80.237]:25320 "EHLO sender-pp-092.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388242AbeGXJvd (ORCPT ); Tue, 24 Jul 2018 05:51:33 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=kt/CtdzRXVJWkaXdAT1401ODDy5I5GXu2CBbrFpQrFpDEKRuohNH5m8CKclsZkijXkr86cJntFIR d7AjwpWkR6a6Ig/6he2RWSZWquatVg7co8yMYXIhsQl4D5XuDaHR Received: from YEHS1XR956R00D1.lenovo.com (123.120.61.139 [123.120.61.139]) by mx.zohomail.com with SMTPS id 1532421938910645.9391778437785; Tue, 24 Jul 2018 01:45:38 -0700 (PDT) From: Huaisheng Ye To: linux-nvdimm@lists.01.org, dan.j.williams@intel.com Cc: ross.zwisler@linux.intel.com, willy@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, viro@zeniv.linux.org.uk, martin.petersen@oracle.com, axboe@kernel.dk, gregkh@linuxfoundation.org, bart.vanassche@wdc.com, jack@suse.cz, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, chengnt@lenovo.com, Huaisheng Ye Subject: [PATCH 2/5] tools/testing/nvdimm: Allow a NULL-kaddr to ->direct_access() Date: Tue, 24 Jul 2018 16:45:07 +0800 Message-Id: <20180724084510.6104-3-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20180724084510.6104-1-yehs2007@zoho.com> References: <20180724084510.6104-1-yehs2007@zoho.com> X-ZohoMailClient: External Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaisheng Ye The mock / test version of pmem_direct_access() needs to check the validity of second rank pointer kaddr for NULL assignment. If kaddr equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye --- 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 b53596a..c3ba159 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -31,7 +31,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (get_nfit_res(pmem->phys_addr + offset)) { struct page *page; - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", @@ -40,7 +41,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, return 1; } - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* -- 1.8.3.1