From patchwork Thu Nov 3 12:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13029963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6358C4321E for ; Thu, 3 Nov 2022 13:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbiKCNB4 (ORCPT ); Thu, 3 Nov 2022 09:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbiKCNBu (ORCPT ); Thu, 3 Nov 2022 09:01:50 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C9B14D10 for ; Thu, 3 Nov 2022 06:01:22 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N33hx0nXwzJnL5; Thu, 3 Nov 2022 20:58:25 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 21:01:20 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 21:01:19 +0800 From: Yang Yingliang To: CC: Yang Yingliang , Karan Tilak Kumar , Sesidhar Baddela , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH 2/2] scsi: snic: fix refcount leak of shost_gendev in normal path Date: Thu, 3 Nov 2022 20:59:38 +0800 Message-ID: <20221103125938.124819-3-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103125938.124819-1-yangyingliang@huawei.com> References: <20221103125938.124819-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The refcount of shost_gendev is get snic_tgt_create(), but it has never been put while module exiting in normal path, so add put_device() in snic_tgt_dev_release() to avoid refcount leak. Fixes: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA") Cc: Karan Tilak Kumar Cc: Sesidhar Baddela Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Signed-off-by: Yang Yingliang --- drivers/scsi/snic/snic_disc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/snic/snic_disc.c b/drivers/scsi/snic/snic_disc.c index 031c27d8510f..d0759391ed1e 100644 --- a/drivers/scsi/snic/snic_disc.c +++ b/drivers/scsi/snic/snic_disc.c @@ -198,6 +198,7 @@ snic_tgt_dev_release(struct device *dev) dev_name(dev)); SNIC_BUG_ON(!list_empty(&tgt->list)); + put_device(dev->parent); kfree(tgt); } @@ -303,7 +304,6 @@ snic_tgt_create(struct snic *snic, struct snic_tgt_id *tgtid) "Snic Tgt: device_add, with err = %d\n", ret); - put_device(&snic->shost->shost_gendev); put_device(&tgt->dev); return NULL; }