Return-Path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:34427 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728936AbfGOCeE (ORCPT ); Sun, 14 Jul 2019 22:34:04 -0400 Received: by mail-pg1-f196.google.com with SMTP id n9so736153pgc.1 for ; Sun, 14 Jul 2019 19:34:03 -0700 (PDT) Subject: Re: [PATCH] mm/gup: Use put_user_page*() instead of put_page*() References: <1563131456-11488-1-git-send-email-linux.bhar@gmail.com> From: Jens Axboe Message-ID: <018ee3d1-e2f0-ca12-9f63-945056c09985@kernel.dk> Date: Sun, 14 Jul 2019 20:33:57 -0600 MIME-Version: 1.0 In-Reply-To: <1563131456-11488-1-git-send-email-linux.bhar@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: xdp-newbies-owner@vger.kernel.org List-ID: To: Bharath Vedartham , akpm@linux-foundation.org, ira.weiny@intel.com, jhubbard@nvidia.com Cc: Mauro Carvalho Chehab , Dimitri Sivanich , Arnd Bergmann , Greg Kroah-Hartman , Alex Williamson , Cornelia Huck , Alexander Viro , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Enrico Weigelt , Thomas Gleixner , Alexios Zavras , Dan Carpenter , Max Filippov , Matt Sickler , "Kirill A. Shutemov" , Keith Busch , YueHaibing , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, kvm@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org On 7/14/19 1:08 PM, Bharath Vedartham wrote: > diff --git a/fs/io_uring.c b/fs/io_uring.c > index 4ef62a4..b4a4549 100644 > --- a/fs/io_uring.c > +++ b/fs/io_uring.c > @@ -2694,10 +2694,9 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg, > * if we did partial map, or found file backed vmas, > * release any pages we did get > */ > - if (pret > 0) { > - for (j = 0; j < pret; j++) > - put_page(pages[j]); > - } > + if (pret > 0) > + put_user_pages(pages, pret); > + > if (ctx->account_mem) > io_unaccount_mem(ctx->user, nr_pages); > kvfree(imu->bvec); You handled just the failure case of the buffer registration, but not the actual free in io_sqe_buffer_unregister(). -- Jens Axboe