From patchwork Wed Apr 12 09:08:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Jia Shi X-Patchwork-Id: 9676887 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 8CE0560383 for ; Wed, 12 Apr 2017 09:08:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EA572848E for ; Wed, 12 Apr 2017 09:08:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73BD02855A; Wed, 12 Apr 2017 09:08:50 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E94102848E for ; Wed, 12 Apr 2017 09:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753560AbdDLJIs (ORCPT ); Wed, 12 Apr 2017 05:08:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48979 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559AbdDLJIp (ORCPT ); Wed, 12 Apr 2017 05:08:45 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3C941dt087834 for ; Wed, 12 Apr 2017 05:08:44 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 29s29rv8s7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Apr 2017 05:08:44 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Apr 2017 03:08:43 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Apr 2017 03:08:40 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3C98c8Y10879440; Wed, 12 Apr 2017 02:08:38 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81F756A042; Wed, 12 Apr 2017 03:08:38 -0600 (MDT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 5D8116A03B; Wed, 12 Apr 2017 03:08:37 -0600 (MDT) From: Dong Jia Shi To: kvm@vger.kernel.org, linux-s390@vger.kernel.org Cc: bjsdjshi@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, dan.carpenter@oracle.com Subject: [PATCH 1/2] vfio: ccw: remove unnecessary NULL checks of a pointer Date: Wed, 12 Apr 2017 11:08:15 +0200 X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170412090816.79108-1-bjsdjshi@linux.vnet.ibm.com> References: <20170412090816.79108-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17041209-0004-0000-0000-000011F34624 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006922; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00846434; UDB=6.00417506; IPR=6.00624870; BA=6.00005284; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015017; XFM=3.00000013; UTC=2017-04-12 09:08:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041209-0005-0000-0000-00007E8F4F49 Message-Id: <20170412090816.79108-2-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-12_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704120076 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove several unnecessary checks for the @private pointer, since it can never be NULL in these places. Reported-by: Dan Carpenter Signed-off-by: Dong Jia Shi --- drivers/s390/cio/vfio_ccw_fsm.c | 6 +----- drivers/s390/cio/vfio_ccw_ops.c | 17 ----------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c index 55b6cc5..80a0559c 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c @@ -161,12 +161,8 @@ static void fsm_io_request(struct vfio_ccw_private *private, static void fsm_irq(struct vfio_ccw_private *private, enum vfio_ccw_event event) { - struct irb *irb; + struct irb *irb = this_cpu_ptr(&cio_irb); - if (!private) - return; - - irb = this_cpu_ptr(&cio_irb); memcpy(&private->irb, irb, sizeof(*irb)); queue_work(vfio_ccw_work_q, &private->io_work); diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index b2e6154..55d0c87 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -19,9 +19,6 @@ static int vfio_ccw_mdev_reset(struct mdev_device *mdev) int ret; private = dev_get_drvdata(mdev_parent_dev(mdev)); - if (!private) - return -ENODEV; - sch = private->sch; /* * TODO: @@ -49,9 +46,6 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb, struct vfio_ccw_private *private = container_of(nb, struct vfio_ccw_private, nb); - if (!private) - return NOTIFY_STOP; - /* * Vendor drivers MUST unpin pages in response to an * invalidation. @@ -134,9 +128,6 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev) dev_get_drvdata(mdev_parent_dev(mdev)); int ret; - if (!private) - goto out; - if ((private->state == VFIO_CCW_STATE_NOT_OPER) || (private->state == VFIO_CCW_STATE_STANDBY)) goto out; @@ -187,9 +178,6 @@ static ssize_t vfio_ccw_mdev_read(struct mdev_device *mdev, return -EINVAL; private = dev_get_drvdata(mdev_parent_dev(mdev)); - if (!private) - return -ENODEV; - region = &private->io_region; if (copy_to_user(buf, (void *)region + *ppos, count)) return -EFAULT; @@ -209,8 +197,6 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev, return -EINVAL; private = dev_get_drvdata(mdev_parent_dev(mdev)); - if (!private) - return -ENODEV; if (private->state != VFIO_CCW_STATE_IDLE) return -EACCES; @@ -274,9 +260,6 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev, return -EINVAL; private = dev_get_drvdata(mdev_parent_dev(mdev)); - if (!private) - return -ENODEV; - ctx = &private->io_trigger; switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) {