Message ID | 20220706075921.2255059-1-niejianglei2021@163.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: cdnsp: Fix potential memory leak in cdnsp_alloc_stream_info() | expand |
On Wed, Jul 06, 2022 at 03:59:21PM +0800, Jianglei Nie wrote: > cdnsp_alloc_stream_info() allocates stream context array for stream_info > ->stream_ctx_array with cdnsp_alloc_stream_ctx(). When some error occurs, > stream_info->stream_ctx_array is not released, which will lead to a > memory leak. > > We can fix it by releasing the stream_info->stream_ctx_array with > cdnsp_free_stream_ctx() on the error path to avoid the potential memory > leak. > > Signed-off-by: Jianglei Nie <niejianglei2021@163.com> > --- > drivers/usb/cdns3/cdnsp-mem.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c > index 97866bfb2da9..319037848151 100644 > --- a/drivers/usb/cdns3/cdnsp-mem.c > +++ b/drivers/usb/cdns3/cdnsp-mem.c > @@ -631,6 +631,7 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev, > stream_info->stream_rings[cur_stream] = NULL; > } > } > + cdnsp_free_stream_ctx(pdev, pep); > > cleanup_stream_rings: > kfree(pep->stream_info.stream_rings); > -- > 2.25.1 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c index 97866bfb2da9..319037848151 100644 --- a/drivers/usb/cdns3/cdnsp-mem.c +++ b/drivers/usb/cdns3/cdnsp-mem.c @@ -631,6 +631,7 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev, stream_info->stream_rings[cur_stream] = NULL; } } + cdnsp_free_stream_ctx(pdev, pep); cleanup_stream_rings: kfree(pep->stream_info.stream_rings);
cdnsp_alloc_stream_info() allocates stream context array for stream_info ->stream_ctx_array with cdnsp_alloc_stream_ctx(). When some error occurs, stream_info->stream_ctx_array is not released, which will lead to a memory leak. We can fix it by releasing the stream_info->stream_ctx_array with cdnsp_free_stream_ctx() on the error path to avoid the potential memory leak. Signed-off-by: Jianglei Nie <niejianglei2021@163.com> --- drivers/usb/cdns3/cdnsp-mem.c | 1 + 1 file changed, 1 insertion(+)