From patchwork Thu Nov 24 11:08:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9445227 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 D846160235 for ; Thu, 24 Nov 2016 11:09:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D277D27CF5 for ; Thu, 24 Nov 2016 11:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6C5F27D76; Thu, 24 Nov 2016 11:09:26 +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, UNPARSEABLE_RELAY 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 27BFB27CF5 for ; Thu, 24 Nov 2016 11:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938853AbcKXLJV (ORCPT ); Thu, 24 Nov 2016 06:09:21 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:21796 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936026AbcKXLJT (ORCPT ); Thu, 24 Nov 2016 06:09:19 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAOB9F8S010658 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Nov 2016 11:09:16 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uAOB9F6t001280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Nov 2016 11:09:15 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id uAOB9Drc012451; Thu, 24 Nov 2016 11:09:14 GMT Received: from mwanda (/154.123.30.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Nov 2016 03:09:12 -0800 Date: Thu, 24 Nov 2016 14:08:50 +0300 From: Dan Carpenter To: Alex Williamson , Kirti Wankhede Cc: kvm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] vfio: vfio_group_get_from_dev() doesn't return error pointers Message-ID: <20161124110849.GF17225@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These are all checking for IS_ERR() but vfio_group_get_from_dev() returns NULL pointers on error. Fixes: c086de818dd8 ("vfio iommu: Add blocking notifier to notify DMA_UNMAP") Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 0aac3ca..952e68c 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1933,8 +1933,8 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage, return -E2BIG; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -EINVAL; ret = vfio_group_add_container_user(group); if (ret) @@ -1982,8 +1982,8 @@ int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn, int npage) return -E2BIG; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -EINVAL; ret = vfio_group_add_container_user(group); if (ret) @@ -2019,8 +2019,8 @@ int vfio_register_notifier(struct device *dev, struct notifier_block *nb) return -EINVAL; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -EINVAL; ret = vfio_group_add_container_user(group); if (ret) @@ -2055,8 +2055,8 @@ int vfio_unregister_notifier(struct device *dev, struct notifier_block *nb) return -EINVAL; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -EINVAL; ret = vfio_group_add_container_user(group); if (ret)