[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9592e3da-a105-b0ec-3fb2-be349c464c2c@gmail.com>
Date: Mon, 12 Oct 2020 10:11:29 +0200
From: Christian König <ckoenig.leichtzumerken@...il.com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
linaro-mm-sig@...ts.linaro.org, dri-devel@...ts.freedesktop.org,
linux-media@...r.kernel.org, chris@...is-wilson.co.uk,
airlied@...hat.com, akpm@...ux-foundation.org, daniel@...ll.ch,
sumit.semwal@...aro.org, willy@...radead.org, jhubbard@...dia.com
Subject: Re: [PATCH 2/6] mm: introduce vma_set_file function v3
Am 09.10.20 um 17:14 schrieb Jason Gunthorpe:
> On Fri, Oct 09, 2020 at 05:03:38PM +0200, Christian König wrote:
>> +/*
>> + * Change backing file, only valid to use during initial VMA setup.
>> + */
>> +void vma_set_file(struct vm_area_struct *vma, struct file *file)
>> +{
>> + if (file)
>> + get_file(file);
>> +
>> + swap(vma->vm_file, file);
>> +
>> + if (file)
>> + fput(file);
>> +}
> fput crashes when file is NULL so the error handling after
> unmap_and_free_vma: can't handle this case, similarly vm_file can't be
> NULL either.
>
> So just simply:
>
> swap(vma->vm_file, file);
> get_file(vma->vm_file);
> fput(file);
>
> Will do?
I was considering this as well, yes.
> Just let it crash if any of them are wrongly NULL.
Mhm, changing from anonymous to file backed or reverse is probably not
such a good idea.
So yes catching those problems early is probably the best approach we
could do.
Going to do this in v4 if nobody objects.
Regards,
Christian.
>
> Jason
Powered by blists - more mailing lists