All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixing libfc memory leaks
@ 2019-12-10 16:57 Igor Druzhinin
  2019-12-10 16:57 ` [PATCH 1/2] scsi: libfc: free response frame from GPN_ID Igor Druzhinin
  2019-12-10 16:57 ` [PATCH 2/2] scsi: libfc: drop extra rport reference in fc_rport_create() Igor Druzhinin
  0 siblings, 2 replies; 3+ messages in thread
From: Igor Druzhinin @ 2019-12-10 16:57 UTC (permalink / raw)
  To: linux-scsi, linux-kernel; +Cc: hare, jejb, martin.petersen, Igor Druzhinin

Igor Druzhinin (2):
  scsi: libfc: free response frame from GPN_ID
  scsi: libfc: drop extra rport reference in fc_rport_create()

 drivers/scsi/libfc/fc_disc.c  | 2 ++
 drivers/scsi/libfc/fc_rport.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.7.4


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

* [PATCH 1/2] scsi: libfc: free response frame from GPN_ID
  2019-12-10 16:57 [PATCH 0/2] Fixing libfc memory leaks Igor Druzhinin
@ 2019-12-10 16:57 ` Igor Druzhinin
  2019-12-10 16:57 ` [PATCH 2/2] scsi: libfc: drop extra rport reference in fc_rport_create() Igor Druzhinin
  1 sibling, 0 replies; 3+ messages in thread
From: Igor Druzhinin @ 2019-12-10 16:57 UTC (permalink / raw)
  To: linux-scsi, linux-kernel; +Cc: hare, jejb, martin.petersen, Igor Druzhinin

fc_disc_gpn_id_resp() should be the last function using it so free it
here to avoid memory leak.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 drivers/scsi/libfc/fc_disc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 9c5f7c9..2b865c6 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -628,6 +628,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
 	}
 out:
 	kref_put(&rdata->kref, fc_rport_destroy);
+	if (!IS_ERR(fp))
+		fc_frame_free(fp);
 }
 
 /**
-- 
2.7.4


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

* [PATCH 2/2] scsi: libfc: drop extra rport reference in fc_rport_create()
  2019-12-10 16:57 [PATCH 0/2] Fixing libfc memory leaks Igor Druzhinin
  2019-12-10 16:57 ` [PATCH 1/2] scsi: libfc: free response frame from GPN_ID Igor Druzhinin
@ 2019-12-10 16:57 ` Igor Druzhinin
  1 sibling, 0 replies; 3+ messages in thread
From: Igor Druzhinin @ 2019-12-10 16:57 UTC (permalink / raw)
  To: linux-scsi, linux-kernel; +Cc: hare, jejb, martin.petersen, Igor Druzhinin

The callers of this function seem to assume the reference is not taken
in case rport already exists. This results in one extra reference taken
on each rport re-discovery that will eventually get to inability to
free rport structure on port removal.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 drivers/scsi/libfc/fc_rport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index da6e97d..a43f9dd 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -133,8 +133,10 @@ struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, u32 port_id)
 	lockdep_assert_held(&lport->disc.disc_mutex);
 
 	rdata = fc_rport_lookup(lport, port_id);
-	if (rdata)
+	if (rdata) {
+		kref_put(&rdata->kref, fc_rport_destroy);
 		return rdata;
+	}
 
 	if (lport->rport_priv_size > 0)
 		rport_priv_size = lport->rport_priv_size;
-- 
2.7.4


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

end of thread, other threads:[~2019-12-10 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 16:57 [PATCH 0/2] Fixing libfc memory leaks Igor Druzhinin
2019-12-10 16:57 ` [PATCH 1/2] scsi: libfc: free response frame from GPN_ID Igor Druzhinin
2019-12-10 16:57 ` [PATCH 2/2] scsi: libfc: drop extra rport reference in fc_rport_create() Igor Druzhinin

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.