Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2314531pxb; Fri, 5 Feb 2021 14:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwthxnErKTzHr8ZdTxEzlSZUobNLpA64Z/p/+vhrM9aEdWItj91xSLIw+Z8+1KsoQMCCL+e X-Received: by 2002:a50:a6ce:: with SMTP id f14mr5742491edc.346.1612565396485; Fri, 05 Feb 2021 14:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612565396; cv=none; d=google.com; s=arc-20160816; b=NmTmiLX+X/BQjkTgZZ4oHfncqnbriCObA5hNFYWhv0vBfy6XpC1gdbcOCf+PNKBfX1 derE0POSC7qSgiqhyBVrAVm38/xn/ldqiELX6EwbGjbkoG6wLHwQfFC7CTZyUrwuEoXG WEeUC/SiDTFNY1y46zDdBivOw5ZGWW8HyImuH09glEznq8MSjUu7apMe7YV7waI/AuWg dhsqTh/I/lOF4JXbIG6HCmk9Z2peC5OehEkDD7ntcuhalPzo/E4kRrznUXEDNggfNRyB 7z81sYsWzrwOkKnfSMdxZykq9tkFRVw+XkqJsBrDLgRJCfRXd874AT2jmetpRDFCPjOK VHJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qXo+zbBXQjG2oE4dPsmHoWWfptixRa/Vrys2AhaFk7o=; b=gFmhnun2NgLbzxHlasd7k+aOw6YeezWVgX7cxp2hUopKRlfktyOjkfWnOtDGKeqVNW zqc0ZnKKYt5TECwWYimDn8+uLyvwE65WIpdpQpqy5RcLfQUI0oWgIiimjIst1IjoSoop 1ipfBn6XW+ChaXWKmb0UdOlqIXmldXSl+9/9d25r5Zxd9LGMozBD183Ie+Y1b+fDm4a7 rPbXS4unWKu8ndFjySCobZIPNKVYkQmMC02N9UM/IZJjMlYOjb2DPgZanTTvYKEGnxh3 63xyJUPXUFB+TpDNiTXATjMnCFrGsmPvp2aDILwF6cCsx8tGUOMqUz4UEB32s2UUDtNS Chfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="teZ/P5gK"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si7433523edy.113.2021.02.05.14.49.32; Fri, 05 Feb 2021 14:49:56 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="teZ/P5gK"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233242AbhBEWqL (ORCPT + 99 others); Fri, 5 Feb 2021 17:46:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:43562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbhBEOqB (ORCPT ); Fri, 5 Feb 2021 09:46:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F26966507A; Fri, 5 Feb 2021 14:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534391; bh=Y+ixUP1Ec25lKYwt/7pjnJG/ADSoVOxNvnDCOXgwmNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=teZ/P5gKoV6brzr6osbe1olqLYo7IYlOmMf1qfk3NU0Lznzqaxj+HULVU0SO7QCUh s1Wk1VFb3V7rLUd2z/QvF3WbhYmIT8AflmqMcpP1cef8xbMfAiaTUY6yP86hflTJa2 P9Be7tKGevH4VcUZ+Fr2pQoC7i06SMuiYMiFg3Cc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karan Tilak Kumar , Dinghao Liu , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 20/32] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 Date: Fri, 5 Feb 2021 15:07:35 +0100 Message-Id: <20210205140653.212222311@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140652.348864025@linuxfoundation.org> References: <20210205140652.348864025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit d6e3ae76728ccde49271d9f5acfebbea0c5625a3 ] When ioread32() returns 0xFFFFFFFF, we should execute cleanup functions like other error handling paths before returning. Link: https://lore.kernel.org/r/20201225083520.22015-1-dinghao.liu@zju.edu.cn Acked-by: Karan Tilak Kumar Signed-off-by: Dinghao Liu Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/fnic/vnic_dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c index 522636e946282..c8bf8c7ada6a7 100644 --- a/drivers/scsi/fnic/vnic_dev.c +++ b/drivers/scsi/fnic/vnic_dev.c @@ -444,7 +444,8 @@ int vnic_dev_init_devcmd2(struct vnic_dev *vdev) fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index); if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */ pr_err("error in devcmd2 init"); - return -ENODEV; + err = -ENODEV; + goto err_free_wq; } /* @@ -460,7 +461,7 @@ int vnic_dev_init_devcmd2(struct vnic_dev *vdev) err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring, DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE); if (err) - goto err_free_wq; + goto err_disable_wq; vdev->devcmd2->result = (struct devcmd2_result *) vdev->devcmd2->results_ring.descs; @@ -481,8 +482,9 @@ int vnic_dev_init_devcmd2(struct vnic_dev *vdev) err_free_desc_ring: vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring); -err_free_wq: +err_disable_wq: vnic_wq_disable(&vdev->devcmd2->wq); +err_free_wq: vnic_wq_free(&vdev->devcmd2->wq); err_free_devcmd2: kfree(vdev->devcmd2); -- 2.27.0