Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4631520pxj; Wed, 12 May 2021 09:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjNdEMBVT6oObdRo+1jsoclgwVEg4nV/LWlR/peRoba/wwqq/h8PhUt6ugZIA65DPcUvOd X-Received: by 2002:a05:6512:c14:: with SMTP id z20mr26047198lfu.277.1620837496195; Wed, 12 May 2021 09:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837496; cv=none; d=google.com; s=arc-20160816; b=OivLbSJxBzF9v4UUubrbmll+DnHtTJMUmWTxM125lUVH3Oi3mAVAbRiuLxDcs42iU4 zNJkeoCdU22hlvybutAu+Dzi6jTA6OD4xu6tDNPchfW++TacAz6Q/8BXKortdR4/62kw D3ow1l6fsvplq//YQpspQ0+kYuEAoVl0EmU1M90/Mva7O0KEvHJ0mWK/l0mTcvl92aLP 4U9N1WZr+jVTdZw7fjivVF4kcJqD+vxw5vce3p7ohA2PlhNgpy9xzXAYj8/S1C0aFB2d 55UGGQRwJVCcSEBGAhYQPnq5KGi0W67/32XEKFNrIvMXQvleOtLmG2H32KNqJrUO8wuY lqmw== 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=XyYihVCjjow8eO7XbcIEmfGLmxUnCQyPxB229QPZbVE=; b=XhkaYL5Wy7oC/L1LOh9enQ22LQy8zVo3nmL/Lgevm1pjCjoVqozFRLwVzxXAzRtwR5 b1iKVlixNWWcZE8ZPiW1YlVJ/AZb4CXE9vkAtIHc5R3QaNWz5fHLksuzH9q3OngPuyu/ NFz9UWMDM+3osrRarqL6El4Jss/gVtXhD4PlUDwzIEslfurXqEGvvmhC9BTnj+8+TsBy 4LhGfesFfwp8D/WVxxWI+G9ygofhMrcuK5rPDtCcESrNNOFV1cS1G+K5VrN0+CoxaW/L Okbh6G/OcXSLjMkeSBdEOCf0HgbcBu3evEP4Fd2mqsLHQ+VG42wIuDmsR4smNwdIXSim bIjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CIjwGrZC; 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 e15si312764ljn.155.2021.05.12.09.37.45; Wed, 12 May 2021 09:38:16 -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=CIjwGrZC; 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 S242450AbhELQeu (ORCPT + 99 others); Wed, 12 May 2021 12:34:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235042AbhELPmV (ORCPT ); Wed, 12 May 2021 11:42:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11C8A61C76; Wed, 12 May 2021 15:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832910; bh=K9YfiBT3PGPhLAmA0zT6LshT9kX7FXrYZhF5Bfk5ViM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CIjwGrZCh5YN55yXY4oRHpAOAhmkf1y16lOZL11cWz1oRRTxPJUffi97USCL4EIAv Pf5cgHVEECIRxkDkqhcSORJ0G9U6LUsLCEiEFTx7m+Ys0Ro3YDcKX7pvO8crfXvCFY nNHN1MLGd4jv9kuHiQqWxD0vz6pgWsBAF71FDM2Y= 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 5.10 471/530] RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Date: Wed, 12 May 2021 16:49:41 +0200 Message-Id: <20210512144835.241281086@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 5f97643e22e5..ae7d227edad2 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