Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1670834ybv; Fri, 21 Feb 2020 01:22:58 -0800 (PST) X-Google-Smtp-Source: APXvYqz/msBSnUePAVyVl8BOI5rUVFOnsD4EKJEam96f9ddiyH7ecpfvYyTYzJ6O+fP9KR2WIOtJ X-Received: by 2002:a05:6830:1615:: with SMTP id g21mr28417142otr.49.1582276977950; Fri, 21 Feb 2020 01:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582276977; cv=none; d=google.com; s=arc-20160816; b=gjO2yRn9eK7Xwa/IyLNb0fpu/4Iw6KuTq+W5uFRczpVLj4+v/epgWVmE3FNuCJpXQV 4suPOiabJgclbFHc2bORQNjUX7zN5lRKa9jmEYmVtlS1FEhYuLZcKIKPKRe42O2BMt5t VXDj0J1nki7R3Z0wJDeRp6TtVw7Mmz2ipac/ijWFaLKx2KVIi7VQKy4XtPIxW5v9jTqj EkCJsZrkYqjPRBMKskbnvqGTRjU8TAn0dTu6ps+/MtqgxtTnTJmi0Zjdm2YrQvFu25Bh P/f8YyOSYx86hTj4T+2uTa/uNCIujF/Ui/Y7mLb2E556tW/kTRjwNuB2CgZ3dQ8qIAZj YgRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=iNSV0maVYrvqtkSV2G4zYbFJ8mQhLTDKQFlpgA8kpO4=; b=ANEAwKamMCxhDWrqNiUU1+CHRX+jYLlJyp9fMhMMsMYD2Lxr1D7da8WCfyfQzKHX20 HOVcGpEztp3X/M4Sv/UZzsiGDPj4FKGOUWVjxeiTMdNS3qzDRnv4q2ecoCp6LEvVai2b 342oydffoxu8zFOjI1n7QcpYhUOGzaJRopHr+U0S5iy/ELdI5i+VNedvX3qX0butYkst qwMqO9DedIIt9Z2ZmkcYVqujAcB0OnARbzm+rF5PcEB/7pJqF5F/XbUa1YbyeLkTLezT rZDotq6f4JxJ5tQIKMAAfMhI/m1SU04wOH9YcnxdSh/QIML9ep//T9SgIuaN4zfE47oP es1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si517107oij.118.2020.02.21.01.22.45; Fri, 21 Feb 2020 01:22:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbgBUJVi (ORCPT + 99 others); Fri, 21 Feb 2020 04:21:38 -0500 Received: from mx2.suse.de ([195.135.220.15]:48518 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbgBUJVi (ORCPT ); Fri, 21 Feb 2020 04:21:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 65871AE5C; Fri, 21 Feb 2020 09:21:36 +0000 (UTC) Subject: Re: [PATCH RESEND 2/2] scsi: libfc: drop extra rport reference in fc_rport_create() To: Igor Druzhinin , fcoe-devel@open-fcoe.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jejb@linux.ibm.com, martin.petersen@oracle.com References: <1579013000-14570-1-git-send-email-igor.druzhinin@citrix.com> <1579013000-14570-3-git-send-email-igor.druzhinin@citrix.com> From: Hannes Reinecke Openpgp: preference=signencrypt Autocrypt: addr=hare@suse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eOCL IvxRPpmMOlcI4WDW3EDkzqNAXn5Onx/b0rFGFpM4GmSPriEJdBb4M4pSD6fN6Y/Jrng/Bdwk SQARAQABiQIlBBgBAgAPBQJOiskRAhsMBQkSzAMAAAoJEGz4yi9OyKjPgEwQAIP/gy/Xqc1q OpzfFScswk3CEoZWSqHxn/fZasa4IzkwhTUmukuIvRew+BzwvrTxhHcz9qQ8hX7iDPTZBcUt ovWPxz+3XfbGqE+q0JunlIsP4N+K/I10nyoGdoFpMFMfDnAiMUiUatHRf9Wsif/nT6oRiPNJ T0EbbeSyIYe+ZOMFfZBVGPqBCbe8YMI+JiZeez8L9JtegxQ6O3EMQ//1eoPJ5mv5lWXLFQfx f4rAcKseM8DE6xs1+1AIsSIG6H+EE3tVm+GdCkBaVAZo2VMVapx9k8RMSlW7vlGEQsHtI0FT c1XNOCGjaP4ITYUiOpfkh+N0nUZVRTxWnJqVPGZ2Nt7xCk7eoJWTSMWmodFlsKSgfblXVfdM 9qoNScM3u0b9iYYuw/ijZ7VtYXFuQdh0XMM/V6zFrLnnhNmg0pnK6hO1LUgZlrxHwLZk5X8F uD/0MCbPmsYUMHPuJd5dSLUFTlejVXIbKTSAMd0tDSP5Ms8Ds84z5eHreiy1ijatqRFWFJRp ZtWlhGRERnDH17PUXDglsOA08HCls0PHx8itYsjYCAyETlxlLApXWdVl9YVwbQpQ+i693t/Y PGu8jotn0++P19d3JwXW8t6TVvBIQ1dRZHx1IxGLMn+CkDJMOmHAUMWTAXX2rf5tUjas8/v2 azzYF4VRJsdl+d0MCaSy8mUh Message-ID: Date: Fri, 21 Feb 2020 10:21:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1579013000-14570-3-git-send-email-igor.druzhinin@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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