Re: [Xen-devel] [PATCH] pvcalls-front: fixes incorrect error handling

From: Boris Ostrovsky
Date: Mon Nov 26 2018 - 15:32:06 EST


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 <bianpan2016@xxxxxxx>
> ---
> 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?

-boris

> + free_page((unsigned long)map->active.ring);
> return ret;
> }
>