Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp49257imu; Mon, 26 Nov 2018 16:59:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBSmkUz6mM8P2UClkUsWQdpf3XME0P1DO/ozR0r2/SxMWA8c5oXTUsDxJeUu9e2YmvGj+0 X-Received: by 2002:a17:902:8a95:: with SMTP id p21mr25597971plo.183.1543280371492; Mon, 26 Nov 2018 16:59:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543280371; cv=none; d=google.com; s=arc-20160816; b=pxtbXNhHiPU+Zi5rrCWLobe0yE19DimqRfD8i/dszQO9vJxJSRfILqP1ImZHuFdejD UUZhqxcz73QY3z+McOhhphKerZ6dPnn1y5HwqS+e5a0qfAZe/m1pVWsIJngOakPU0bTV w2A8IDd6Zj+Pk0fto5LWkyY/ZeMLOioGlij93ipMju6jkHOdntw2fgzej0D91UMW2YAY zU2AQCUzqwx02LGH1NfsOtd6nzYyotW4JqQLMmQKoitXCYOKp63+w6qnYZ61QHdmnjPe QpowC0fa7cvunnekpNqK2DnqcyDSWBvrRVxROWSIKI5ArDmQB0nvfo1Wui0/1TFB3BGZ 792w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=yNuIuRMSYL/aoMcojHqluyNNc4n3j+uR47c8cisLZmE=; b=LeWBe+RLvYyLerZZ4ujLmhNG+Oj02mFm6vkm1Fzr8iCMCjlGQ75/TdqzQyyP0GuzQ8 XxDGzOTMYX/tas3tDukdpJ+kqMacfDZyj8JXclg1KIGXycFeS2/q6Rogn165BuklGcYi UYyoJ4ARtUZGnyflwSz86BuUJc/ZHMC8moJalVcMFWYvdlgzelRLm1m2jb8W5V1BxgaV G5OanHk5eoY5X23n8LwR08PkDVuVYJ5zMWmFYl297UdXQmPVsGgG1d9L6KAPVySW4x2y gU8hl1SGn6AedpDdyxRhHdhRxJ45ZKUJUw2M9TkaJc+2ubYSrfE0T6reNAn7wdZ0ldLx 4Wrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=bV71GiCI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si2038117pll.112.2018.11.26.16.59.15; Mon, 26 Nov 2018 16:59:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=bV71GiCI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727653AbeK0Lyl (ORCPT + 99 others); Tue, 27 Nov 2018 06:54:41 -0500 Received: from m12-13.163.com ([220.181.12.13]:51077 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbeK0Lyl (ORCPT ); Tue, 27 Nov 2018 06:54:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=yNuIu RMSYL/aoMcojHqluyNNc4n3j+uR47c8cisLZmE=; b=bV71GiCIwlrW/qUeRT8XO TeXCqf5dTgIdeALB9lecvl4SJUepncKSmMcf+lqPdJzq256J2NLAoceqUSlie0YT ToPzn8aycz4vBWgtXvvGB1kKKacbRVQM5m7hQ2Nscivn7f07P/OfCKrLQ+YjL6oe VXnW8zGbp0/GuzAFsNnj9I= Received: from bp (unknown [106.120.213.96]) by smtp9 (Coremail) with SMTP id DcCowADHIsWulvxbHu37Bw--.23962S2; Tue, 27 Nov 2018 08:58:22 +0800 (CST) Date: Tue, 27 Nov 2018 08:58:23 +0800 From: PanBian To: Boris Ostrovsky Cc: Juergen Gross , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: Re: [Xen-devel] [PATCH] pvcalls-front: fixes incorrect error handling Message-ID: <20181127005823.GB125510@bp> Reply-To: PanBian References: <1542852432-30019-1-git-send-email-bianpan2016@163.com> <1f765e81-ed89-d110-74b1-cc8029a4555f@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f765e81-ed89-d110-74b1-cc8029a4555f@oracle.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CM-TRANSID: DcCowADHIsWulvxbHu37Bw--.23962S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WrW3ur1DXw45tFy3GF1UGFg_yoW8XrWrpF s7JF1jyF48tasayrZFqa1Yvry5Za1Iq348Wry2kan0kr13CFy8tFyFk34v9w4v9r4rGF1f Zw4jqFy7CFsxA37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j_hL8UUUUU= X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiDg8MclXlpnQALgAAsz Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 03:31:39PM -0500, Boris Ostrovsky wrote: > On 11/21/18 9:07 PM, Pan Bian wrote: > > kfree() is incorrectly used to release the pages allocated by > > __get_free_page() and __get_free_pages(). Use the matching deallocators > > i.e., free_page() and free_pages(), respectively. > > > > Signed-off-by: Pan Bian > > --- > > drivers/xen/pvcalls-front.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c > > index 2f11ca7..77224d8 100644 > > --- a/drivers/xen/pvcalls-front.c > > +++ b/drivers/xen/pvcalls-front.c > > @@ -385,8 +385,8 @@ static int create_active(struct sock_mapping *map, int *evtchn) > > out_error: > > if (*evtchn >= 0) > > xenbus_free_evtchn(pvcalls_front_dev, *evtchn); > > - kfree(map->active.data.in); > > - kfree(map->active.ring); > > + free_pages((unsigned long)map->active.data.in, PVCALLS_RING_ORDER); > > Is map->active.data.in guaranteed to be NULL when entering this routine? I am not sure yet. Sorry for that. I observed the mismatches between __get_free_page and kfree, and submitted the patch. But I think your consideration is reasonable. A better solution is to directly free bytes, a local variable that holds __get_free_pages return value. If you agree, I will rewrite the patch. Thanks, Pan > > -boris > > > + free_page((unsigned long)map->active.ring); > > return ret; > > } > > >