Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3209361pxf; Mon, 22 Mar 2021 00:04:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFLlAEp5AGMXg6VY03AjdShF3ZnjLi6pyq0/U72MI33YmMmtkqo/F555FWAfNLGjuNYPZf X-Received: by 2002:aa7:dd97:: with SMTP id g23mr23766759edv.154.1616396674163; Mon, 22 Mar 2021 00:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616396674; cv=none; d=google.com; s=arc-20160816; b=ZiKTudFDrfRncR0hy6Z8vNR9RhShYSXLwJd9vjuZYAzbke57eXjY78bczGwaMam4wi AryQ8rNO4XS/nScOsQH8g4rN/M9rbi2d1ym3anxO6g8rh+4H+tEhAB/x8m3y034L30sl V7cJeVaoTIfMn2nVh2ezxantVOTd0Tc5PRjgvp6RJ4YHcaFHL6F+VTR49ds3gNV+cEpf CwP9TVzOE1fmPjB8/H2ho99siTWFEw3cREZNycSvMCBHdm1UheRoIfsWF5T5BDEj7IkH mjqeTf4438gv/F9ax7lmztZewP3JqzaQjFwP34aNlY2YQ/jaaqTnvlHprf+nnU4LUgRF 5tYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gJBkP2u3ctuYT48zyZQ9ngGF/nTc36GmqSbC4CdukE8=; b=FRrc0uSGY+MXRzYOn8YlL4P4+udJsRtWTDnCNeQPSJhEoVjlrCquwYnlqNduuw9Wcz 9I7NHXVzFWTlTSmNVa3yS6ktAjAqU/HMUI2DZfLr2GnUzAqW/J2nhl/Y0HF1tN38E3LJ 4MQRQ0ESLPv5EV/7B3rbhlC1hWnJQ5gjZ5OaYQI5nx9H/1/JTEKd2nYjJUl1lYu2HPyj R2/fp9JLsK1BhXbiBCjs/ECliWgUH8+Na0Se7ymlbtLyTp7cPHaHbfkjj/3lHsEUDHUP PlqzZj7728vZh2qX8euFUv7piHmulY6cEuklRwsq3Mc4mcwqVSW4Mg+wLUxgbh1X6oNr rwZQ== ARC-Authentication-Results: i=1; mx.google.com; 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 k24si10426950ejs.280.2021.03.22.00.04.12; Mon, 22 Mar 2021 00:04:34 -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; 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 S229547AbhCVHDM (ORCPT + 99 others); Mon, 22 Mar 2021 03:03:12 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:47100 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbhCVHC4 (ORCPT ); Mon, 22 Mar 2021 03:02:56 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lOEaT-00852M-Ht; Mon, 22 Mar 2021 07:02:53 +0000 Date: Mon, 22 Mar 2021 07:02:53 +0000 From: Al Viro To: Namjae Jeon Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-cifsd-devel@lists.sourceforge.net, smfrench@gmail.com, senozhatsky@chromium.org, hyc.lee@gmail.com, hch@lst.de, hch@infradead.org, ronniesahlberg@gmail.com, aurelien.aptel@gmail.com, aaptel@suse.com, sandeen@sandeen.net, dan.carpenter@oracle.com, colin.king@canonical.com, rdunlap@infradead.org, Sergey Senozhatsky , Steve French Subject: Re: [PATCH 3/5] cifsd: add file operations Message-ID: References: <20210322051344.1706-1-namjae.jeon@samsung.com> <20210322051344.1706-4-namjae.jeon@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210322051344.1706-4-namjae.jeon@samsung.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 02:13:42PM +0900, Namjae Jeon wrote: > +static struct ksmbd_file *__ksmbd_lookup_fd(struct ksmbd_file_table *ft, > + unsigned int id) > +{ > + bool unclaimed = true; > + struct ksmbd_file *fp; > + > + read_lock(&ft->lock); > + fp = idr_find(ft->idr, id); > + if (fp) > + fp = ksmbd_fp_get(fp); > + > + if (fp && fp->f_ci) { > + read_lock(&fp->f_ci->m_lock); > + unclaimed = list_empty(&fp->node); > + read_unlock(&fp->f_ci->m_lock); > + } > + read_unlock(&ft->lock); > + > + if (fp && unclaimed) { > + atomic_dec(&fp->refcount); > + return NULL; > + } Can that atomic_dec() end up dropping the last remaining reference? If not, what's to prevent that?