Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376549

Re: [PATCH v2] usb: dwc3: fix memory leak of dwc->regset

From Felipe Balbi <balbi@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] usb: dwc3: fix memory leak of dwc->regset
Date 2016-04-12 10:30 +0200
Message-ID <rn1RT-421-1@gated-at.bofh.it> (permalink)
References <rmZZL-2Fs-1@gated-at.bofh.it> <rn1RT-421-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

changbin.du@intel.com writes:
> From: "Du, Changbin" <changbin.du@intel.com>
>
> dwc->regset is allocated on dwc3_debugfs_init, and should
> be released on init failure or dwc3_debugfs_exit. Btw,
> The line "dwc->root = NULL" is unnecessary, so remove it.
>
> Signed-off-by: Du, Changbin <changbin.du@intel.com>
> ---
> v2:
>   Title changed;
>   free dwc->regset on failure path.
>
> ---
>  drivers/usb/dwc3/debugfs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> index 9ac37fe..abd8889 100644
> --- a/drivers/usb/dwc3/debugfs.c
> +++ b/drivers/usb/dwc3/debugfs.c
> @@ -678,7 +678,8 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
>  
>  err1:
>  	debugfs_remove_recursive(root);
> -
> +	if (!dwc->regset)
> +		kfree(dwc->regset);

IOW:

        if regset is NULL, free NULL.

This check is wrong and unnecessary ;-) kfree(NULL) is safe.

-- 
balbi

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit changbin.du@intel.com - 2016-04-08 12:00 +0200
  Re: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit Felipe Balbi <balbi@kernel.org> - 2016-04-11 10:10 +0200
    RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit "Du, Changbin" <changbin.du@intel.com> - 2016-04-11 13:10 +0200
      RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit Felipe Balbi <balbi@kernel.org> - 2016-04-11 13:20 +0200
        RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit "Du, Changbin" <changbin.du@intel.com> - 2016-04-11 13:40 +0200
          RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit Felipe Balbi <balbi@kernel.org> - 2016-04-11 14:20 +0200
            RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit "Du, Changbin" <changbin.du@intel.com> - 2016-04-12 04:20 +0200
              RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit Felipe Balbi <balbi@kernel.org> - 2016-04-12 08:30 +0200
                RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit "Du, Changbin" <changbin.du@intel.com> - 2016-04-12 09:00 +0200
                RE: [PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit Felipe Balbi <balbi@kernel.org> - 2016-04-12 10:10 +0200
                Re: [PATCH v2] usb: dwc3: fix memory leak of dwc->regset Felipe Balbi <balbi@kernel.org> - 2016-04-12 10:30 +0200
                [PATCH v3] usb: dwc3: fix memory leak of dwc->regset changbin.du@intel.com - 2016-04-12 10:40 +0200
                Re: [PATCH v3] usb: dwc3: fix memory leak of dwc->regset Felipe Balbi <balbi@kernel.org> - 2016-04-12 12:20 +0200
                [PATCH v2] usb: dwc3: fix memory leak of dwc->regset changbin.du@intel.com - 2016-04-12 10:30 +0200

csiph-web