Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2899608pxk; Sun, 6 Sep 2020 18:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy6eShr/kUV4CSecFbemERzPSrIdVzHzLCpkygRLjr5ExbeFOPPBUX0F2qvZDNEYg7XBxs X-Received: by 2002:a17:906:4151:: with SMTP id l17mr20196596ejk.116.1599442736385; Sun, 06 Sep 2020 18:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599442736; cv=none; d=google.com; s=arc-20160816; b=fz4odPqHDYWeGPpAf8UmEZIO+//hDygv9pTGmGvAfZueT6sexWKLOUGBKDcDDmIJPR I/YOlhJc6IsGxvpueXoSv+RF/g9Fk865eRqRp1E0t27px64c6Y8CRqjB/IZYcPxTHlRC AbkEFo3hWfSDSCQpAhLvKarEqNG///uK7j48ipJthG8A+XNiZlWa9A3AEpMRdRnCKS5t ZNhzshymBZSEElEswy2BG9BmJZU9Yv05T04Eh5mUAdemTqCpyUtzyq6+nMkhybFeDXTl X3qBhusXNtv6HU3ShgLN6Lfw6lLoNzHIA6X93+IzIIuJEGE58GoytHOol9AtlaWVMXnt QGkg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=zhbEzc/yW4BYKjoq9HRcXXwlVDMrkx4c7pNW/jtkpsk=; b=Bqcxxyb/AZPj4x5Ahqxs8ROI1RNRIoeLeh1AA5Tn8rNxeGDVky0OPfwNx9/qYR87Ga 0wh8fekISAqFmLCVKhCq/iupUSZoAy2Swdrdkk+/ycOwKra9VQB5+f03w6N15Z9Pp8vw BC6kmA2byQwKYhTHC3Hwtzb+j+pLTwqhyixn4aBfr+DEUojitTOoHRFyDY+6mgqvsaRX 0SpWXDqLbXJqARDO7cY6i+WnReiILF6TyK1mCgX/fpETB1/liCxdGUzrdNFnQEpRZyVJ 41zCwyfv+j2yqSejVlfCfJPrS2oTxcsP8z2d8HZG7p2Nu7LD7HE0/pwykNXzcW2i8Qr5 DQyg== 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 m18si1197662eja.292.2020.09.06.18.38.34; Sun, 06 Sep 2020 18:38:56 -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 S1726939AbgIGBhS (ORCPT + 99 others); Sun, 6 Sep 2020 21:37:18 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60238 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726620AbgIGBhS (ORCPT ); Sun, 6 Sep 2020 21:37:18 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DB7DE54EDDC5E93ECC73; Mon, 7 Sep 2020 09:37:15 +0800 (CST) Received: from [127.0.0.1] (10.174.179.92) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Sep 2020 09:37:06 +0800 Subject: Re: [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() To: Dan Carpenter , "James E.J. Bottomley" , Dan Williams CC: "Martin K. Petersen" , John Garry , "Gustavo A. R. Silva" , , , References: <20200905125836.GF183976@mwanda> From: Jason Yan Message-ID: Date: Mon, 7 Sep 2020 09:37:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200905125836.GF183976@mwanda> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.92] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2020/9/5 20:58, Dan Carpenter ะด??: > In sas_notify_lldd_dev_found(), if we can't find a device, then it seems > like the wrong thing to mark the device as found and to increment the > reference count. None of the callers ever drop the reference in that > situation. > > Fixes: 735f7d2fedf5 ("[SCSI] libsas: fix domain_device leak") > Signed-off-by: Dan Carpenter > --- > drivers/scsi/libsas/sas_discover.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c > index cd7c7d269f6f..d0f9e90e3279 100644 > --- a/drivers/scsi/libsas/sas_discover.c > +++ b/drivers/scsi/libsas/sas_discover.c > @@ -182,10 +182,11 @@ int sas_notify_lldd_dev_found(struct domain_device *dev) > pr_warn("driver on host %s cannot handle device %016llx, error:%d\n", > dev_name(sas_ha->dev), > SAS_ADDR(dev->sas_addr), res); > + return res; > } > set_bit(SAS_DEV_FOUND, &dev->state); > kref_get(&dev->kref); > - return res; > + return 0; > } > > > Hi Dan, thanks for finding this, Reviewed-by: Jason Yan