From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D802FC07E99 for ; Fri, 9 Jul 2021 13:02:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBCC1613CA for ; Fri, 9 Jul 2021 13:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231605AbhGINFF (ORCPT ); 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-hyperv@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.