Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6724078imm; Tue, 24 Jul 2018 01:47:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenGZ6bqxKe23Ovr6qXSqzyMx+fMzPDTEogi7n/TVArz51DUqJj9pwlxiDzOWBj3RLvghRP X-Received: by 2002:a63:2803:: with SMTP id o3-v6mr15612359pgo.158.1532422038426; Tue, 24 Jul 2018 01:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532422038; cv=none; d=google.com; s=arc-20160816; b=SpyMfvdJi36OpOne54bPrUQiQsU9zUW0xZQseIu46uqUUJEpDfBQRZRkruQnDsq6UN /W3c5VczuomtU2ZR1Fdy5XotFJSDSJ+JjTB9K2Y5hpWE3spVuU90vVBzpnm+rtZWhHQm TzqNzLKyHkeyO8JVGE9yYt3JjGkuahJVVyxueMcsPr6xDw9tNFGVQAEKt6QLagK1bEnv Rc33UsYO/10hesq48YTVjDu+G+OOQpBFqkKCOTyZ4kzespZ0lc0AiDHKl3+MJOrz2+Uf SNNJSHZYe2yPaTPy5w9Fb9IhDCZwdJ9i1h/lk9/Ums919MmfnrWgaliizIb6ozw63S44 t50g== 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=EX1kGgMq6f7ob6QRCCOBjIKou3PvPCucIEsxiOzTDnE=; b=Kzof9MzgcTan3utY/0gI2a0K0KAACfcLP40T5IXElDqQw6Jd1CyPKhoKTaTLEGmuX7 rl4JDxRBzrybuyB7rGz15K6LDKNyqQNcelfIsrY2Casdiqv1/XVzjCNLzszjkyR2HjtR wMgzlIA+HX+VQzbl3kELx1E0x/8bvcEYkpIJMXmfq6qT7ACPpzZ86/17Js8sdDrizJn6 DGH+gnaf1vAucIfRtnXwvlGTTeTumf0zMQNNOanoJv2cQlz4+rr1JuuMo6vMtsSBjZOy QY26rEvY1i7HYmpGdwgdZ1psPBX9RT/++Vl5pgK5g8pxmdN65u/gMnBqn9/nuB/e77V3 w4dw== 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 j33-v6si10188492pld.151.2018.07.24.01.47.03; Tue, 24 Jul 2018 01:47:18 -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 S2388149AbeGXJvZ (ORCPT + 99 others); Tue, 24 Jul 2018 05:51:25 -0400 Received: from sender-pp-092.zoho.com ([135.84.80.237]:25456 "EHLO sender-pp-092.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726759AbeGXJvZ (ORCPT ); Tue, 24 Jul 2018 05:51:25 -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=o8DzimMISHmA8PMXYakCBguq+ZdUf6NJcgo6rp6pkTjx2+Y29VZiUWUfveTjlI29OW9B3247C5Tf meOUl6SJwiXP6peMd3PtdU3Duo+M80zAmTLgooOsiGs9a4Q/sZF1 Received: from YEHS1XR956R00D1.lenovo.com (123.120.61.139 [123.120.61.139]) by mx.zohomail.com with SMTPS id 1532421932354323.0936250512914; Tue, 24 Jul 2018 01:45:32 -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 1/5] libnvdimm, pmem: Allow a NULL-kaddr to ->direct_access() Date: Tue, 24 Jul 2018 16:45:06 +0800 Message-Id: <20180724084510.6104-2-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 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 --- drivers/nvdimm/pmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9d71492..b1d121a 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -232,7 +232,9 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages)))) return -EIO; - *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