Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp347356pxj; Thu, 20 May 2021 10:39:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgd6HRrFeW3uG7OeOM/DTMcFu1kW3N1FuZAUglwpkGncb8b1Uj83l6ruMwCyALOCXdsc8U X-Received: by 2002:a17:906:d1d2:: with SMTP id bs18mr5916875ejb.56.1621532391574; Thu, 20 May 2021 10:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532391; cv=none; d=google.com; s=arc-20160816; b=zkNiIQpy7U2R9iz9Kxd45Bx421mZxT3L8qZy1cFv8WsO8g1J8zakv3/W3/69jSG7u8 +sJ4pNq/UJZxqtOAHH/bcDriA4rEogxuxHqhApMMImnQvhfxG8U2EOBsIE3thUHH1HgR zSYayfpt/+lAt/orMChY+WpLPEIBxrAU1+HUZgXriTSbmDnD9EuF0G0TUsqOQL4YljPG AD8D1Z4hVMFMGEAYFHasSuHfzFljAwJ9+SZuwQ1bjdXUFyXxj3aZba2tSoXgi8wR/ILw 3FoIiELD91qwTITPez4I/tmCLezfDgeZGuhFqjQkW2Phm2q4pXOuXYRdW7DF2ZM7VYH0 qPrw== 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=J7WIaGpb6ow4kzg0t4Bb53F2CHWci8aMTQQI5mWBpU0=; b=y6ZvOElslj/s2vkCKy6fLsI+LpUcyi6shN51j3rofBJK9f+D61jNwmmtjnjFinmrgM gM8upFjltsW3O/vzfITQpHy3xPDhEat0pce8AzN20sBpFXjJ/tDaY+HMYBBNAvf1mzeA Mdy5CBsJYJJuiqYDCUxtGQjdLaYxCKZ8NXqmD9Gb2AorVrQeHN8jBfwgJqkKk4W6MpOS GXZ6Od/QUV2MD9ctyszjFyBS1jMOP9ApB9SGy3qevhV7nLh5+JKTVWGcOmB1q9p7AkHp y/k548dky+DDwTNuIcgT1ZN0Qc3iPly9o78RxJuI+r9LvQrZxdw0tKAu58m8LhlnszAR dngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mMkAWDBN; 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 w10si2292006edd.545.2021.05.20.10.39.27; Thu, 20 May 2021 10:39:51 -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=mMkAWDBN; 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 S235434AbhETKGs (ORCPT + 99 others); Thu, 20 May 2021 06:06:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:36868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234936AbhETKB3 (ORCPT ); Thu, 20 May 2021 06:01:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9ED86191D; Thu, 20 May 2021 09:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503566; bh=wc2f9ho+L9XPJcFs4VOnTopaVG8HjPKl2gTGzl3PhmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMkAWDBN+yPYvltJXvNTaXpQipxcfnjnHtnT0cmwy9qLc6c6+UoZl5HekwEJc4Zyp 5JZK5wHNAwwbZ6HYUWSPk+rxVY7DsRXC8A+owbWHV2VLFvGdN5ACYNFLeQQ+EODdHT KWn7Fjno0kNmA0ZBn/pjE+0snZfnr7x+yFDE7knM= 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.19 279/425] RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Date: Thu, 20 May 2021 11:20:48 +0200 Message-Id: <20210520092140.609763390@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 540aab5e502d..3fafc5424e76 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_pble.c +++ b/drivers/infiniband/hw/i40iw/i40iw_pble.c @@ -392,12 +392,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); @@ -408,6 +405,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