From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759770AbdADMWr (ORCPT ); Wed, 4 Jan 2017 07:22:47 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:1665 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753418AbdADMWo (ORCPT ); Wed, 4 Jan 2017 07:22:44 -0500 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 04 Jan 2017 04:22:43 -0800 Subject: Re: [PATCH] samples/vfio-mdev: don't return zero on failure paths in mtty_dev_init() To: Alexey Khoroshilov , Neo Jia , Alex Williamson References: <1483137629-18500-1-git-send-email-khoroshilov@ispras.ru> CC: , , X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: Date: Wed, 4 Jan 2017 17:52:30 +0530 MIME-Version: 1.0 In-Reply-To: <1483137629-18500-1-git-send-email-khoroshilov@ispras.ru> X-Originating-IP: [10.24.216.210] X-ClientProxiedBy: DRUKMAIL102.nvidia.com (10.25.59.20) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan Carpenter had sent similar change earlier. https://www.spinics.net/lists/kvm/msg141470.html Alex, Did you pull that change in your tree? Thanks, Kirti On 12/31/2016 4:10 AM, Alexey Khoroshilov wrote: > If class_create() or mdev_register_device() fail, mtty_dev_init() > breaks off initialization, deallocates all resources, but returns zero. > > The patch adds proper error code return values. > > Found by Linux Driver Verification project (linuxtesting.org). > > Signed-off-by: Alexey Khoroshilov > --- > samples/vfio-mdev/mtty.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c > index 6b633a4ea333..e9c52e1f97a6 100644 > --- a/samples/vfio-mdev/mtty.c > +++ b/samples/vfio-mdev/mtty.c > @@ -1446,6 +1446,7 @@ static int __init mtty_dev_init(void) > mtty_dev.vd_class = class_create(THIS_MODULE, MTTY_CLASS_NAME); > > if (IS_ERR(mtty_dev.vd_class)) { > + ret = PTR_ERR(mtty_dev.vd_class); > pr_err("Error: failed to register mtty_dev class\n"); > goto failed1; > } > @@ -1458,7 +1459,8 @@ static int __init mtty_dev_init(void) > if (ret) > goto failed2; > > - if (mdev_register_device(&mtty_dev.dev, &mdev_fops) != 0) > + ret = mdev_register_device(&mtty_dev.dev, &mdev_fops); > + if (ret) > goto failed3; > > mutex_init(&mdev_list_lock); > @@ -1467,11 +1469,9 @@ static int __init mtty_dev_init(void) > goto all_done; > > failed3: > - > device_unregister(&mtty_dev.dev); > failed2: > class_destroy(mtty_dev.vd_class); > - > failed1: > cdev_del(&mtty_dev.vd_cdev); > unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK); >