Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3063925pxk; Mon, 7 Sep 2020 02:01:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCdKBZdvuy3rxbdlDa3WHZo2KfclbsJU66jXS8m+Iml+Hef6EYyaERtlSUu4nfC7GllOki X-Received: by 2002:a17:906:1186:: with SMTP id n6mr19077696eja.331.1599469263429; Mon, 07 Sep 2020 02:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599469263; cv=none; d=google.com; s=arc-20160816; b=DSej9lucBzRaEvfcMHfys1lDIH1EwvWFt9ecb4m4Un0H0XW3TOHo0BMJ+lZD41dXi6 MKHymBRmjtAkuF9GKmGk86W/lwLLiDCKDllFuQadGymeEoKzEoW8L0HcAvaHS7tLVHVM xFwDIZdeVJuAwV2ge7JJqnwil4rzYxej2SmlCpBOnp5/eoWiynwH24XD/Yb8nCqStLlf aiKmEvtrBceSkOIXvhhlCO2ymhQTgTEIIdOiEs3w5hZzGWaKYIOUtdVN7vYglUMRP1Lz AERHYoMppZwqsNBptP0YOxnqhNuRhxMllb0PrzYJJaazrgvvv7SIHR8sSHmqUTRbpkK+ +SWg== 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:references:cc:to:subject:from; bh=eJjZuZowqq7Ma5ODsQZf4+vWTlPHq5aUHJZJyLJanig=; b=hf92eiU+jDr2AGsV5VkGi9DAhaEBov5iuz7YxX33Zvus01wUe3KV7y9H8yRHdoVVUu TnNnNu9DK37BGg6k7WQ0IqHOmzkcBXoXpVZlQcGJE+WSqHb4TWZM9nYKzu7HUMYtuCr7 2c+oh4O0h5gfyi7qlbT6kXmd7bmaxKv1lfuR8GStziMYLZKgRTCX73mOHezUGodhNlHZ 8eG3/fcgSBZ/OUpl00Tm8LDFMoXj3OEfJdK+LD1Wg4PwLFCbsUOgp7amlwbunwIPxfHu j4VYkoJwICBo8b9dasZ+1hmdZjFc/thi2wbFRMFHGRiQ7ONa+JSgowYul46ZnDF4pc8q 6Swg== 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 bs11si9148182edb.90.2020.09.07.02.00.41; Mon, 07 Sep 2020 02:01:03 -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 S1728244AbgIGI5a (ORCPT + 99 others); Mon, 7 Sep 2020 04:57:30 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2772 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727953AbgIGI5a (ORCPT ); Mon, 7 Sep 2020 04:57:30 -0400 Received: from lhreml724-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 2C5D77505446F7B84C87; Mon, 7 Sep 2020 09:57:28 +0100 (IST) Received: from [127.0.0.1] (10.47.2.208) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Mon, 7 Sep 2020 09:57:27 +0100 From: John Garry 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" , "Gustavo A. R. Silva" , Jason Yan , , , References: <20200905125836.GF183976@mwanda> Message-ID: <4ef45b15-34fd-80e9-1adb-53044ca9fa84@huawei.com> Date: Mon, 7 Sep 2020 09:54:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200905125836.GF183976@mwanda> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.2.208] X-ClientProxiedBy: lhreml726-chm.china.huawei.com (10.201.108.77) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2020 13:58, Dan Carpenter wrote: > In sas_notify_lldd_dev_found(), if we can't find a device, nit: the callback is for the LLDD is to allocate resources, device context etc., for that domain_device, and not find the device. The device has been found at this point. > 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; This looks ok. > } Thanks, John > > >