Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1148719ybs; Mon, 25 May 2020 08:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNLZBFQzEkitguj4sNgr3D6fvlAGHapOEIfyfb01tB6cVJC54XxryoAEWG++eYOmt0EAWl X-Received: by 2002:a17:906:39c3:: with SMTP id i3mr20090183eje.417.1590419729266; Mon, 25 May 2020 08:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590419729; cv=none; d=google.com; s=arc-20160816; b=FUZnzM42FmBL53JNu60B0hQsX7wKbKszT022e9zKUHFqLhjKFvSvDTBfGA1zxe9E7u S34JJZ6vfrT+/mDrg1eBBzZSGbwt5dDHYfUDKDiHm5k76mG3ik25MkbTMCH3uUkVaxjg tT+fLE5fj16yF5l/JTISXi3Hx2ug+36b3i9PU6qLvaidcXRhOVXY843N3HrNslGIjEVR nv1gelOP/eb6LdSU1HeTiz7KEaqdiYeBpZzeq1pmZZrB+Gaj+HJUKLRW6+Fgxeq7dvHe el/1LAGZ2D1DJC7unLk6jLqOAYYjsalVJkzOh7MwjCgRFYUg71+A9zi7uf3UnS1u9JiS aIOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9qplGzFjMm9+5M79W/o9dPIoZiKHARTHOq8qAMBU7sE=; b=kFNYsHkmRboMH/R3vuE//5PJDWRjVPrqDWYozSrZp+t++4O98NNZowNtTIDmqglS9p Of7MA+rmQ8OhQu5yX07ZZF1be8LBbWm8ACO7UvIRgjEG58zK11IH36ThtUNWwx4hmXzY KMwe3BzFIYYiyK75NdE7KRcyeVe84lhubzEU6LKQZmnYFspS5wKUhjSYPlmLouMXL2Oa IfkyGND+he1WfxWjAjBhCgR/BwTWbDctKr1mjubsfCsXHfyBw8Baq4rMikceJnye0plD qjnLcdsQxCJ9S1OGiYQsawi9BZNOMWNQg/bRvVw1KQ8YTIHxESQzIwn9n0xZ2cuBp+sJ ibNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si11192974edn.487.2020.05.25.08.15.05; Mon, 25 May 2020 08:15:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391063AbgEYPMX (ORCPT + 99 others); Mon, 25 May 2020 11:12:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:54936 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390992AbgEYPMX (ORCPT ); Mon, 25 May 2020 11:12:23 -0400 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 794F6B13C; Mon, 25 May 2020 15:12:24 +0000 (UTC) Date: Mon, 25 May 2020 17:12:20 +0200 From: Daniel Wagner To: Xiyu Yang Cc: James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Xin Tan Subject: Re: [PATCH] scsi: lpfc: Fix lpfc_nodelist leak when processing unsolicited event Message-ID: <20200525151220.rtwmlobnkmhwhxn5@beryllium.lan> References: <1590416184-52592-1-git-send-email-xiyuyang19@fudan.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590416184-52592-1-git-send-email-xiyuyang19@fudan.edu.cn> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, May 25, 2020 at 10:16:24PM +0800, Xiyu Yang wrote: > In order to create or activate a new node, lpfc_els_unsol_buffer() > invokes lpfc_nlp_init() or lpfc_enable_node() or lpfc_nlp_get(), all of > them will return a reference of the specified lpfc_nodelist object to > "ndlp" with increased refcnt. lpfc_enable_node() is not changing the refcnt. > When lpfc_els_unsol_buffer() returns, local variable "ndlp" becomes > invalid, so the refcount should be decreased to keep refcount balanced. > > The reference counting issue happens in one exception handling path of > lpfc_els_unsol_buffer(). When "ndlp" in DEV_LOSS, the function forgets > to decrease the refcnt increased by lpfc_nlp_init() or > lpfc_enable_node() or lpfc_nlp_get(), causing a refcnt leak. > > Fix this issue by calling lpfc_nlp_put() when "ndlp" in DEV_LOSS. This sounds reasonable. At least the lpfc_nlp_init() and lpfc_nlp_get() case needs this. And I suppose this is also ok for the lfpc_enable_node(). Reviewed-by: Daniel Wagner Thanks, Daniel