Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1150565rwr; Fri, 5 May 2023 09:46:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vT/hL14nk1cEoTgm56f7ZFdE2b16q/vM1Kib7tYgzC3pYxr3k/H9vR8GhuGN31Om3k7h9 X-Received: by 2002:a17:902:db08:b0:1a6:7b71:e64b with SMTP id m8-20020a170902db0800b001a67b71e64bmr9792508plx.15.1683305216859; Fri, 05 May 2023 09:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683305216; cv=none; d=google.com; s=arc-20160816; b=t9+WSbnLHUNHV3guz4XzS1woaaV3n9xC3hGf/o9Q6Lopnad0urA1kWJC/xEzKoc1tn zXNJErVaxbZDX77kKUCGCbSYCV3Q/rIF6BDGsUOhXGyvd1KrVAuyggDvNw2N0OzczmvT e/Q/m4JpKjmRnILbpQrdIIdHcggJiOvK8JO6QMIxQcxGtX6LE1/mBf4/80KJmpZzFlWC rX3vklRzMv7P6yMs06i/D8ATBgXrrn4wHCnBoooQOqTercdl0jZqtfVdX5ElDWkfoYNG KbmoQy5JNfOHPVnixq2Fj0UU+HZHkLOAdiwIwfRzVOS2e39LsagvJTRuEA0WQawGm48S J/EQ== 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=Nlm81eQ07bNOljC7pSbx2Y0ij6ymZ8q+vKEc3A/8hfw=; b=NgFKDMDBP07O9k+65hlCAQWps6DyizNwgaXwbM4VkFKCiuoLDNDDQsjOh6pL0oTWlu oK7xM81fSHDQRvPmKHEuP6VQByp/f1aFewNA/VE8uPMrp5HNQ6q6aJ5GbmP+x6K5plUB ehhv119pA2IcEGKOumEyP2hAWszzGrY+icaEp9qo9tSswGAxcmSM6qtsn0AD2EYZ++qy gPjOal9Wp4Xkrpuq0kvWv7TbM6IMh0f8upVdqN9YXnN7SaUyVBUv7JQ61nJo5e0QSwjO 1ZnZp23AVjhz5djS86uinngeegz0S7ApQqiBlA/4w0HHA8o5BPP3uxCGu0nhz22CI//w N2fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z5oSX760; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a170902e54200b001a6fce1d951si1587661plf.377.2023.05.05.09.46.41; Fri, 05 May 2023 09:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z5oSX760; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbjEEQcl (ORCPT + 99 others); Fri, 5 May 2023 12:32:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232583AbjEEQck (ORCPT ); Fri, 5 May 2023 12:32:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D30A255; Fri, 5 May 2023 09:32:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F2CD60F13; Fri, 5 May 2023 16:32:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B0FCC433EF; Fri, 5 May 2023 16:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683304358; bh=F8Pcuij3dAuNBRRdWfXIz2M2vKjF/5eyboVxzllRmRc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z5oSX760hWQUUvH9I9I8xdaoGa0plTsNBol4+OrtEvmrAzYY620KWn21VGTpWfBGq BiWZPBvFU4drrP/tn6/OhwxVlaow/+EOkiEMu5EVKi9XIdkU9VKAobDDqFt7+fZsHx A4ji6S5ehEirWrVQWDuP9qZyGcBmDRvSZEt/tZVfU1DPfpqdL/LHIg/2hhb8fx+jeh ku3ASXI2zmXtNrcOMmWzTROLJ3FmVs2ZKmPIZSjmP/KE9GanAiT1K6pJ/UWy0P1a2X 7mfalGE3Nts2TEK9dPoTjYroAGVFDv7h21x4L2lXFBbicx1Ej0ct1NzWXlPUa4OmWr znWSyYhdL8jrQ== Date: Fri, 5 May 2023 19:32:34 +0300 From: Leon Romanovsky To: ye.xingchen@zte.com.cn Cc: jgg@ziepe.ca, jiangjian@cdjrlc.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] RDMA/core: Use fdget() and fdput() Message-ID: <20230505163234.GB525452@unreal> References: <202305051133576690069@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202305051133576690069@zte.com.cn> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 05, 2023 at 11:33:57AM +0800, ye.xingchen@zte.com.cn wrote: > From: Ye Xingchen > > convert the fget()/fput() uses to fdget()/fdput(). Why? What is wrong with current implementation? Thanks > > Signed-off-by: Ye Xingchen > --- > drivers/infiniband/core/rdma_core.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c > index 29b1ab1d5f93..c35df0b27e86 100644 > --- a/drivers/infiniband/core/rdma_core.c > +++ b/drivers/infiniband/core/rdma_core.c > @@ -335,7 +335,7 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj, > enum rdma_lookup_mode mode) > { > const struct uverbs_obj_fd_type *fd_type; > - struct file *f; > + struct fd f = fdget(fdno); > struct ib_uobject *uobject; > int fdno = id; > > @@ -350,18 +350,17 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj, > fd_type = > container_of(obj->type_attrs, struct uverbs_obj_fd_type, type); > > - f = fget(fdno); > - if (!f) > + if (!f.file) > return ERR_PTR(-EBADF); > > - uobject = f->private_data; > + uobject = f.file->private_data; > /* > * fget(id) ensures we are not currently running > * uverbs_uobject_fd_release(), and the caller is expected to ensure > * that release is never done while a call to lookup is possible. > */ > - if (f->f_op != fd_type->fops || uobject->ufile != ufile) { > - fput(f); > + if (f.file->f_op != fd_type->fops || uobject->ufile != ufile) { > + fdput(f); > return ERR_PTR(-EBADF); > } > > -- > 2.25.1