diff mbox

fbdev: broadsheetfb: fix memory leak

Message ID 1442574992-31654-1-git-send-email-sudipm.mukherjee@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sudip Mukherjee Sept. 18, 2015, 11:16 a.m. UTC
On the error path we have missed releasing the firmware.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/video/fbdev/broadsheetfb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Tomi Valkeinen Sept. 24, 2015, 10:12 a.m. UTC | #1
On 18/09/15 14:16, Sudip Mukherjee wrote:
> On the error path we have missed releasing the firmware.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/video/fbdev/broadsheetfb.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c
> index 0e5fde1..ac1f41e 100644
> --- a/drivers/video/fbdev/broadsheetfb.c
> +++ b/drivers/video/fbdev/broadsheetfb.c
> @@ -752,7 +752,7 @@ static ssize_t broadsheet_loadstore_waveform(struct device *dev,
>  	if ((fw_entry->size < 8*1024) || (fw_entry->size > 64*1024)) {
>  		dev_err(dev, "Invalid waveform\n");
>  		err = -EINVAL;
> -		goto err_failed;
> +		goto err_fw;
>  	}
>  
>  	mutex_lock(&(par->io_lock));
> @@ -762,13 +762,15 @@ static ssize_t broadsheet_loadstore_waveform(struct device *dev,
>  	mutex_unlock(&(par->io_lock));
>  	if (err < 0) {
>  		dev_err(dev, "Failed to store broadsheet waveform\n");
> -		goto err_failed;
> +		goto err_fw;
>  	}
>  
>  	dev_info(dev, "Stored broadsheet waveform, size %zd\n", fw_entry->size);
>  
>  	return len;
>  
> +err_fw:
> +	release_firmware(fw_entry);
>  err_failed:
>  	return err;
>  }

This looks like correct fix, but where is the firmware released when
there is no error?

 Tomi
Sudip Mukherjee Sept. 25, 2015, 1:44 p.m. UTC | #2
On Thu, Sep 24, 2015 at 01:12:48PM +0300, Tomi Valkeinen wrote:
> 
> On 18/09/15 14:16, Sudip Mukherjee wrote:
> > On the error path we have missed releasing the firmware.
> > 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
<snip>
> 
> This looks like correct fix, but where is the firmware released when
> there is no error?
I will send v2. Usually all the memleaks will be in the error path so I
concentrate on that part. Sorry, should have looked fully.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c
index 0e5fde1..ac1f41e 100644
--- a/drivers/video/fbdev/broadsheetfb.c
+++ b/drivers/video/fbdev/broadsheetfb.c
@@ -752,7 +752,7 @@  static ssize_t broadsheet_loadstore_waveform(struct device *dev,
 	if ((fw_entry->size < 8*1024) || (fw_entry->size > 64*1024)) {
 		dev_err(dev, "Invalid waveform\n");
 		err = -EINVAL;
-		goto err_failed;
+		goto err_fw;
 	}
 
 	mutex_lock(&(par->io_lock));
@@ -762,13 +762,15 @@  static ssize_t broadsheet_loadstore_waveform(struct device *dev,
 	mutex_unlock(&(par->io_lock));
 	if (err < 0) {
 		dev_err(dev, "Failed to store broadsheet waveform\n");
-		goto err_failed;
+		goto err_fw;
 	}
 
 	dev_info(dev, "Stored broadsheet waveform, size %zd\n", fw_entry->size);
 
 	return len;
 
+err_fw:
+	release_firmware(fw_entry);
 err_failed:
 	return err;
 }