Re: [PATCH 5.2 10/20] media: radio-raremono: change devm_k*alloc to k*alloc
From: Luke Nowakowski-Krijger
Date: Tue Aug 06 2019 - 01:34:38 EST
Hi there,
On Fri, Aug 02, 2019 at 03:04:25AM -0700, Joe Perches wrote:
> On Fri, 2019-08-02 at 11:40 +0200, Greg Kroah-Hartman wrote:
> > From: Luke Nowakowski-Krijger <lnowakow@xxxxxxxxxxxx>
> >
> > commit c666355e60ddb4748ead3bdd983e3f7f2224aaf0 upstream.
> >
> > Change devm_k*alloc to k*alloc to manually allocate memory
> >
> > The manual allocation and freeing of memory is necessary because when
> > the USB radio is disconnected, the memory associated with devm_k*alloc
> > is freed. Meaning if we still have unresolved references to the radio
> > device, then we get use-after-free errors.
> >
> > This patch fixes this by manually allocating memory, and freeing it in
> > the v4l2.release callback that gets called when the last radio device
> > exits.
>
> This really should be commented in the code
> and not just in the commit changelog as some
> unsuspecting person will likely undo this in
> the future without one.
You reckon I should submit a patch with the necessary parts commented?
Thanks,
- Luke