Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp990029imm; Wed, 25 Jul 2018 09:32:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBmV554FMZdpDVrw24To18NRPuZZgUEqOgvhmn3CEs/XFUrAj1qE0wiHkJaGk7iU4GvI8e X-Received: by 2002:a17:902:9a47:: with SMTP id x7-v6mr13134203plv.37.1532536319972; Wed, 25 Jul 2018 09:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532536319; cv=none; d=google.com; s=arc-20160816; b=GPYFTLdbTBRCS/VQ6Aj9GqakU29K0U38CcuDFEQU9+ch8xABUFJeQPBzIq2nnArvDJ kZ7KQDKXZqNinMjQSpJyycQUx2o8gk2RpyyHsGuCqw868LgvuiTpQIFLV6DLH8ftu7bF 9VaLiKZiSyPlHdiCBN1n4iiwi/7+EZZWvdpBmvR86x1Nz8AzOCKb+/OwXIyCBHkc8jvF fBz49jy/B20YjO0L0UsrS80FOinn/BRllLBI+7gNXaFvNCzDGFscFQ4WaV/huSNpw8CG tGjt5evV8WHfod1SFzK/JFEeKKwVSfDItuZXhxyraS+Am23dmaAkSiYz2P/J8JQMPi12 /+MA== 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=wxRLGzSFNnArm2KY6lljliDkC42FVSddxQhxoeMY30Y=; b=pJ1l21H24Sle4OKPE1MUPwdiL9MRJSa0Pz7hzgTmLBDfueYWxkrMYZIO1iV8VXhbIk 2Ue+tyRWK5ok4c13vXoh9beXaGMiPdLaOlZk9EHYINfO0PEf0cEFesPPVGAoKnKx4GUf Ru6wsSE/XIhgI/u94L6VRLkxx2+SkMPf1CUl7qKAYOU7SAJNRRb19JPddJGHQ4A3q9lU IkIjxQfTghkwKBtZ4yX1LBeQkgJhlqDDOXr+23HQqVf/gRv0J+evtA3wBqRbGX+We1a0 xMYjDMeFGV4R4kKEfxAUZ+CUfOZsFPdXvSlVL1pz7G61tSxiwGuRa0LCfEUPJLfNxYBj T7kA== 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 y186-v6si14400410pgb.395.2018.07.25.09.31.44; Wed, 25 Jul 2018 09:31:59 -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 S1729351AbeGYRmR (ORCPT + 99 others); Wed, 25 Jul 2018 13:42:17 -0400 Received: from sender-pp-092.zoho.com ([135.84.80.237]:25494 "EHLO sender-pp-092.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728542AbeGYRmR (ORCPT ); Wed, 25 Jul 2018 13:42:17 -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=fCbn3xBrPGxPROX/ClekHXzJkXfrE4ajrGtdYSk1LZREq7bPBZZrY7aAMGrMuv1/aN26qqtcFhWE 23z6YdEM3mk6JqEjjQDOvfK55UQakHM29TgRdF6i5B2p71bCQnih Received: from YEHS1XR956R00D1.lenovo.com (114.245.13.10 [114.245.13.10]) by mx.zohomail.com with SMTPS id 1532536166941927.3898531496442; Wed, 25 Jul 2018 09:29:26 -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, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, chengnt@lenovo.com, colyli@suse.de, Huaisheng Ye Subject: [PATCH v2 2/6] s390, dcssblk: kaddr and pfn can be NULL to ->direct_access() Date: Thu, 26 Jul 2018 00:28:45 +0800 Message-Id: <20180725162849.8320-3-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20180725162849.8320-1-yehs2007@zoho.com> References: <20180725162849.8320-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 dcssblk_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If either of them is equal to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a pointer or local variable that they then just throw away. Signed-off-by: Huaisheng Ye --- drivers/s390/block/dcssblk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index ed60728..23e526c 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -922,9 +922,11 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, unsigned long dev_sz; dev_sz = dev_info->end - dev_info->start + 1; - *kaddr = (void *) dev_info->start + offset; - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), - PFN_DEV|PFN_SPECIAL); + if (kaddr) + *kaddr = (void *) dev_info->start + offset; + if (pfn) + *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), + PFN_DEV|PFN_SPECIAL); return (dev_sz - offset) / PAGE_SIZE; } -- 1.8.3.1