From: Hannes Reinecke <hare@suse.de>
To: Igor Druzhinin <igor.druzhinin@citrix.com>,
fcoe-devel@open-fcoe.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: jejb@linux.ibm.com, martin.petersen@oracle.com
Subject: Re: [PATCH RESEND 2/2] scsi: libfc: drop extra rport reference in fc_rport_create()
Date: Fri, 21 Feb 2020 10:21:36 +0100 [thread overview]
Message-ID: <cdaf7362-b0dd-de99-b7ec-318b60b85192@suse.de> (raw)
In-Reply-To: <1579013000-14570-3-git-send-email-igor.druzhinin@citrix.com>
On 1/14/20 3:43 PM, Igor Druzhinin wrote:
> 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;
>
NAK.
The caller _does_ assume that a reference is taken once
fc_rport_create() returns non-NULL.
And the caller is responsible to drop the reference once 'rdatat' isn't
used anymore.
Any other usage is an error, but should be fixed in the caller, not here.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
next prev parent reply other threads:[~2020-02-21 9:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 14:43 [PATCH RESEND 0/2] Fixing libfc memory leaks Igor Druzhinin
2020-01-14 14:43 ` [PATCH RESEND 1/2] scsi: libfc: free response frame from GPN_ID Igor Druzhinin
2020-02-21 9:18 ` Hannes Reinecke
2020-02-21 22:56 ` Martin K. Petersen
2020-01-14 14:43 ` [PATCH RESEND 2/2] scsi: libfc: drop extra rport reference in fc_rport_create() Igor Druzhinin
2020-02-21 9:21 ` Hannes Reinecke [this message]
2020-01-21 4:56 ` [PATCH RESEND 0/2] Fixing libfc memory leaks Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cdaf7362-b0dd-de99-b7ec-318b60b85192@suse.de \
--to=hare@suse.de \
--cc=fcoe-devel@open-fcoe.org \
--cc=igor.druzhinin@citrix.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®