Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp637724pxv; Fri, 9 Jul 2021 06:03:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw58Hbm86T35BFZXo029I2KERynU9Az0GWqUfaQW0gM/P7DGz+DFOhMRDySCEL44jQ+qCjQ X-Received: by 2002:a92:c644:: with SMTP id 4mr5223908ill.246.1625835812247; Fri, 09 Jul 2021 06:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625835812; cv=none; d=google.com; s=arc-20160816; b=sfMA6ugequa+2KXxkb2EbdHy7G1pZhzgrnX4fu1oX2PCC7sR9t2druHEEMZeMGYyjL 1sMwTCwXdcaO6duO+qRC5KXopQAw3qeA9cNH8tXHJXWVsOQOyAlSA30f+0J1JHNyhGFL zhChQYvZkIVuqHZ0Pg/AxmPjKpoUT2cL0R/ez3z08uGMHPZB+O127wErI2W1ktyRWKJW 69ijfq76lWcZl10tN2G3rU8XkIFueeXmJ3b1jo9DOo5VkmHtYPY2/B4PKbGxU09dOfYR KPUdyHGTAgqY4R+uT3hwIpa+XUtuQIQ7ZX59wPDEPOMZcfN88rxO+SXVgPIvABV8pMyv 7tow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Tf2SqeGSrDZMCCTM8CYLzkNNDskM5g3U5XmDMVPfYxg=; b=l+tUkcfS8q/QLE3XABMjOBn80HK0FyrEvsOsbSyF2vuaJ3DLFnCb7Wj6z4tvh5YuR/ gc5tayeHKIko22LxBD5cKi8hDNpB4S236AoxioBwxjkUoKr6Wnfg9ioxz9qDCxgeikuj bk6UHDeTC7F2wr+NmCkUtsbOzf4b0hetqjSIQxY13H8Sh/C8QOUsabbbesNqEV5e1HO8 td4vIfimmAD+Af7iDAFqEUzqIA5tbUYyQsRwehIh6a+U9Al5AfwWVVUoytLnumjAawfP 4uwOxUshb7a7Hxb2v6d++fjSeF1U9ipz1Cc2+gDPs01b30IsiJvukwtdxySkgb5TcbDF sG/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QCxP0xW+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si2672025jao.15.2021.07.09.06.03.06; Fri, 09 Jul 2021 06:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QCxP0xW+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231623AbhGINFF (ORCPT + 99 others); Fri, 9 Jul 2021 09:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbhGINFE (ORCPT ); Fri, 9 Jul 2021 09:05:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B6BC0613DD; Fri, 9 Jul 2021 06:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Tf2SqeGSrDZMCCTM8CYLzkNNDskM5g3U5XmDMVPfYxg=; b=QCxP0xW+GMne1FeOeWigUwFFQU gCzkCHtzvH87Ef2OzhfSBF2zR8IzSSl1WVWn0ORHedDsAMfkIJGl4UhpL68a+BPjiF4Kx0mEpY5l+ vZnt1GfzjXbL8vGSfEZC7vk3JuRz8QsSzi4gvmeBhUiDgQHVQbuMHqTUqCr6VGoPeXLk7gzKQbaVH 8wz4m2m3IHK9ZgbkbSqbxqOX2d0zc18GgLtrdDvsVF++lohd0hWJpYfLu2jOtN1zrukUGSyrPSdDl UV6xi77F0Wh1hsI+/uHUX5MXjY1KQsLVB4YQYdUzhD588MPFViUliB3IzCCHG7Y6G2oSOapoRGzLb 9NiZd2wQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1q8q-00EWCS-Av; Fri, 09 Jul 2021 13:02:08 +0000 Date: Fri, 9 Jul 2021 14:02:04 +0100 From: Matthew Wilcox To: Wei Liu Cc: Linux on Hyper-V List , virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , kumarpraveen@linux.microsoft.com, pasha.tatashin@soleen.com, Jonathan Corbet , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Lillian Grassin-Drake , Muminul Islam , "open list:DOCUMENTATION" Subject: Re: [RFC v1 7/8] mshv: implement in-kernel device framework Message-ID: References: <20210709114339.3467637-1-wei.liu@kernel.org> <20210709114339.3467637-8-wei.liu@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210709114339.3467637-8-wei.liu@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 09, 2021 at 11:43:38AM +0000, Wei Liu wrote: > +static long > +mshv_partition_ioctl_create_device(struct mshv_partition *partition, > + void __user *user_args) > +{ [...] > + mshv_partition_get(partition); > + r = anon_inode_getfd(ops->name, &mshv_device_fops, dev, O_RDWR | O_CLOEXEC); > + if (r < 0) { > + mshv_partition_put_no_destroy(partition); > + list_del(&dev->partition_node); > + ops->destroy(dev); > + goto out; > + } > + > + cd->fd = r; > + r = 0; Why return the fd in memory instead of returning the fd as the return value from the ioctl? > + if (copy_to_user(user_args, &tmp, sizeof(tmp))) { > + r = -EFAULT; > + goto out; > + } ... this could then disappear.