All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] infiniband: hfi1: fix a memory leak bug
@ 2019-08-18 19:29 Wenwen Wang
  2019-08-19 11:59 ` Leon Romanovsky
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wenwen Wang @ 2019-08-18 19:29 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Mike Marciniszyn, Dennis Dalessandro, Doug Ledford,
	Jason Gunthorpe, open list:HFI1 DRIVER, open list

In fault_opcodes_read(), 'data' is not deallocated if debugfs_file_get()
fails, leading to a memory leak. To fix this bug, introduce the 'free_data'
label to free 'data' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/infiniband/hw/hfi1/fault.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/fault.c b/drivers/infiniband/hw/hfi1/fault.c
index 93613e5..814324d 100644
--- a/drivers/infiniband/hw/hfi1/fault.c
+++ b/drivers/infiniband/hw/hfi1/fault.c
@@ -214,7 +214,7 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf,
 		return -ENOMEM;
 	ret = debugfs_file_get(file->f_path.dentry);
 	if (unlikely(ret))
-		return ret;
+		goto free_data;
 	bit = find_first_bit(fault->opcodes, bitsize);
 	while (bit < bitsize) {
 		zero = find_next_zero_bit(fault->opcodes, bitsize, bit);
@@ -232,6 +232,7 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf,
 	data[size - 1] = '\n';
 	data[size] = '\0';
 	ret = simple_read_from_buffer(buf, len, pos, data, size);
+free_data:
 	kfree(data);
 	return ret;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] infiniband: hfi1: fix a memory leak bug
  2019-08-18 19:29 [PATCH] infiniband: hfi1: fix a memory leak bug Wenwen Wang
@ 2019-08-19 11:59 ` Leon Romanovsky
  2019-08-19 13:07 ` Dennis Dalessandro
  2019-08-20 17:26 ` Doug Ledford
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2019-08-19 11:59 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Mike Marciniszyn, Dennis Dalessandro, Doug Ledford,
	Jason Gunthorpe, open list:HFI1 DRIVER, open list

On Sun, Aug 18, 2019 at 02:29:31PM -0500, Wenwen Wang wrote:
> In fault_opcodes_read(), 'data' is not deallocated if debugfs_file_get()
> fails, leading to a memory leak. To fix this bug, introduce the 'free_data'
> label to free 'data' before returning the error.
>
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
>  drivers/infiniband/hw/hfi1/fault.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] infiniband: hfi1: fix a memory leak bug
  2019-08-18 19:29 [PATCH] infiniband: hfi1: fix a memory leak bug Wenwen Wang
  2019-08-19 11:59 ` Leon Romanovsky
@ 2019-08-19 13:07 ` Dennis Dalessandro
  2019-08-20 17:26 ` Doug Ledford
  2 siblings, 0 replies; 4+ messages in thread
From: Dennis Dalessandro @ 2019-08-19 13:07 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Mike Marciniszyn, Doug Ledford, Jason Gunthorpe,
	open list:HFI1 DRIVER, open list

On 8/18/2019 3:29 PM, Wenwen Wang wrote:
> In fault_opcodes_read(), 'data' is not deallocated if debugfs_file_get()
> fails, leading to a memory leak. To fix this bug, introduce the 'free_data'
> label to free 'data' before returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] infiniband: hfi1: fix a memory leak bug
  2019-08-18 19:29 [PATCH] infiniband: hfi1: fix a memory leak bug Wenwen Wang
  2019-08-19 11:59 ` Leon Romanovsky
  2019-08-19 13:07 ` Dennis Dalessandro
@ 2019-08-20 17:26 ` Doug Ledford
  2 siblings, 0 replies; 4+ messages in thread
From: Doug Ledford @ 2019-08-20 17:26 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Mike Marciniszyn, Dennis Dalessandro, Jason Gunthorpe,
	open list:HFI1 DRIVER, open list

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

On Sun, 2019-08-18 at 14:29 -0500, Wenwen Wang wrote:
> In fault_opcodes_read(), 'data' is not deallocated if
> debugfs_file_get()
> fails, leading to a memory leak. To fix this bug, introduce the
> 'free_data'
> label to free 'data' before returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Applied to for-rc, thanks.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-20 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-18 19:29 [PATCH] infiniband: hfi1: fix a memory leak bug Wenwen Wang
2019-08-19 11:59 ` Leon Romanovsky
2019-08-19 13:07 ` Dennis Dalessandro
2019-08-20 17:26 ` Doug Ledford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.