From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id A7844A6A for ; Mon, 23 Mar 2015 15:36:48 +0100 (CET) Received: by wixw10 with SMTP id w10so64724365wix.0 for ; Mon, 23 Mar 2015 07:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mirantis.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6ipwPSys+N3WibLiTAi2noFLCt+sYs+1puq9Rz+pxvE=; b=f0SsGCmB1WkMYqc1+i1z8ltfQEgfAdfod2XGLzritKa4gDLf0cOpfBFnZI9cy3NPB1 Yi6aENwPRRk036/T6muy5efSvjteOYyTNCgsN1HrYSwShpIHn8GLXOU5Ljy3nGxUL2Va uPgnKnL/6lPZnwHgCh/2x6Loc8sVK3wlog9zk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=6ipwPSys+N3WibLiTAi2noFLCt+sYs+1puq9Rz+pxvE=; b=f4SSP0vhEFI3rY/0UxvxCefefHxLxjyRTVvk+jgONnWws748V83TcEuPYuk3TeYWj3 U9WxJXE2uHhaVYHlpCxC/BGmZyu9BO0ABjmBqgTFnGYJf0RAdjK807oC73Dst3EvLduX ZAns2DDM4B138bnXyJMNCRFXW/AydeVuI3s9THgDqnOH/HMqdCKJCW8EMSGXlFGbF61h C6pAn2hks9Z0TDWReSQ3D3Dmzgwtpne39H46ZXc5bxEW+/oZqxcCnAIgLd7871rdj8Wc TquddkHl5MhPsNlD5Eq9erMYOx5clcwFN9JgBu+sJ62RO9UHy+qtxp77XnuCp5muqQMj YCfA== X-Gm-Message-State: ALoCoQml44BonN4A9azdyqlwKPu5RZHn6A3hrIJj3HEei+yb5QLERi0HyaEORQiDeWFPtynuFBjZ MIME-Version: 1.0 X-Received: by 10.194.91.129 with SMTP id ce1mr143299111wjb.53.1427121408466; Mon, 23 Mar 2015 07:36:48 -0700 (PDT) Received: by 10.194.76.7 with HTTP; Mon, 23 Mar 2015 07:36:48 -0700 (PDT) In-Reply-To: References: <1427115225-14489-1-git-send-email-pboldin@mirantis.com> Date: Mon, 23 Mar 2015 16:36:48 +0200 Message-ID: From: Pavel Boldin To: "Xie, Huawei" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] vhost: Fix `struct file' leakage in `eventfd_link' X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 14:36:48 -0000 On Mon, Mar 23, 2015 at 4:21 PM, Xie, Huawei wrote: > On 3/23/2015 8:54 PM, Pavel Boldin wrote: > > Due to increased `struct file's reference counter subsequent call > > to `filp_close' does not free the `struct file'. Prepend `fput' call > > to decrease the reference counter. > > > > Signed-off-by: Pavel Boldin > > --- > > lib/librte_vhost/eventfd_link/eventfd_link.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/lib/librte_vhost/eventfd_link/eventfd_link.c > b/lib/librte_vhost/eventfd_link/eventfd_link.c > > index 7755dd6..62c45c8 100644 > > --- a/lib/librte_vhost/eventfd_link/eventfd_link.c > > +++ b/lib/librte_vhost/eventfd_link/eventfd_link.c > > @@ -117,6 +117,7 @@ eventfd_link_ioctl(struct file *f, unsigned int > ioctl, unsigned long arg) > > * Release the existing eventfd in the source process > > */ > > spin_lock(&files->file_lock); > > + fput(file); > Could we just call atomic_long_dec here? > We can but I don't like breaking encapsulation (which is broken anyway by the code). So, there is a special method and we should use it in my opinion. Pavel > filp_close(file, files); > > fdt = files_fdtable(files); > > fdt->fd[eventfd_copy.source_fd] = NULL; > >