Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp547265pxj; Thu, 20 May 2021 15:55:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe4aycun7+jK3IxAg+L3GIPWLQv4h4NwSXUOObSIS4K2Km49FuR9M2pl/oL2OlfioLSsZ5 X-Received: by 2002:a50:bae6:: with SMTP id x93mr7499957ede.48.1621551329523; Thu, 20 May 2021 15:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621551329; cv=none; d=google.com; s=arc-20160816; b=R76odxt5sZq0uOTguUQ7KVaC+zLy7IC9yoyHQ2qaKkQ3o7T6WwieBaLbEgFwwDF43m Ha1XNsxaVr5DGA/18iaCSrJw3cCm6nTeUBwEiLPc3BbnAKcWL1BQogtgMgz72Zs8Gu25 RpCAD2v4qIXOK8qyFbE6vKU4T902SwDeODHxzVpBtmgMiEouU8LqpHVfP8MPxrHvFzpW LGXstViq6Yonl7XgDPEkRMvj/oQWSbsM2ggSrHW2oOQ2D0KSmoJ5jzPeGNiiLJ065fM0 zuj/vUWjT5n4C9MSYTDbTEL9fjBMkn9cOZOChn1eojalfpsx4iN78/q0h79dhZbXUE7s VZXg== 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=gg/6UL54gUF7nELeSOPVgkCUsQk7IkBwbTpTCI43TIk=; b=F/YUzkQW6baz1F1NA7Xvrb1YZ24EziA3Df+n9xgY3RZTta+xCD5SeCSgi6vzq1mqay wJ58U7BGU4FYms9ppSEZXLbzRx/VM/i/zOOH7VzVm1uyOTLqF6cATknPsLme1pJPzRJV wVtPap/l9g9w0VV0WvQlES7CB6w48mw/UHopYcB75pqV4CEK0cPXS3LhnTO2eZsP8Kpj ZU6zamm+ePF+QtTjlFYNMNAGqr8E+hHuJaQMbLTYHGbF85NFeIP3Go0T4o1aLTF7EH4+ B7Xi5MaO3kN2eVrp0+7LC5alFHjqtGXN4R8nigOi0G6UnpLku+m5c1C2qyggCK/20OxA 8l3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bnhMmFQy; 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 nc38si4578569ejc.118.2021.05.20.15.55.06; Thu, 20 May 2021 15:55: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bnhMmFQy; 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 S240687AbhETLTI (ORCPT + 99 others); Thu, 20 May 2021 07:19:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:57500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239320AbhETK6w (ORCPT ); Thu, 20 May 2021 06:58:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 606C861421; Thu, 20 May 2021 10:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504958; bh=Oxr172v+jW+nHUqF3ibUswf6vwqloYXdfpCdU61+TEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bnhMmFQyNv+6Z2c2IfC+9+an5RDEKLgC73j0JU5tWy27otwGWSpaTHVMVZLKUlNYJ 4JgtGPFIdHF+lw6+L/q7YF4QXzdJcW35qgWkGdltIbpY9jhaFUOX6kD52l2VI5KKNx OBN2GJQJcg7Adgw2CmCOCQbqCDy5OnFzEojEW7OI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Sindhu Devale , Shiraz Saleem , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.9 159/240] RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Date: Thu, 20 May 2021 11:22:31 +0200 Message-Id: <20210520092113.991636474@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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: Sindhu Devale [ Upstream commit 783a11bf2400e5d5c42a943c3083dc0330751842 ] When i40iw_hmc_sd_one fails, chunk is freed without the deletion of chunk entry in the PBLE info list. Fix it by adding the chunk entry to the PBLE info list only after successful addition of SD in i40iw_hmc_sd_one. This fixes a static checker warning reported here: https://lore.kernel.org/linux-rdma/YHV4CFXzqTm23AOZ@mwanda/ Fixes: 9715830157be ("i40iw: add pble resource files") Link: https://lore.kernel.org/r/20210416002104.323-1-shiraz.saleem@intel.com Reported-by: Dan Carpenter Signed-off-by: Sindhu Devale Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/i40iw/i40iw_pble.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/i40iw/i40iw_pble.c b/drivers/infiniband/hw/i40iw/i40iw_pble.c index 85993dc44f6e..3fbf7a3b00de 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_pble.c +++ b/drivers/infiniband/hw/i40iw/i40iw_pble.c @@ -399,12 +399,9 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev, i40iw_debug(dev, I40IW_DEBUG_PBLE, "next_fpm_addr = %llx chunk_size[%u] = 0x%x\n", pble_rsrc->next_fpm_addr, chunk->size, chunk->size); pble_rsrc->unallocated_pble -= (chunk->size >> 3); - list_add(&chunk->list, &pble_rsrc->pinfo.clist); sd_reg_val = (sd_entry_type == I40IW_SD_TYPE_PAGED) ? sd_entry->u.pd_table.pd_page_addr.pa : sd_entry->u.bp.addr.pa; - if (sd_entry->valid) - return 0; - if (dev->is_pf) { + if (dev->is_pf && !sd_entry->valid) { ret_code = i40iw_hmc_sd_one(dev, hmc_info->hmc_fn_id, sd_reg_val, idx->sd_idx, sd_entry->entry_type, true); @@ -415,6 +412,7 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev, } sd_entry->valid = true; + list_add(&chunk->list, &pble_rsrc->pinfo.clist); return 0; error: kfree(chunk); -- 2.30.2