Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2119050lkv; Thu, 20 May 2021 03:51:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW4iXh5mYHzITOy+DxdgHsyU9cm4VeCgWFAfjqHQVFJTU9XtGc7b8NDk0o9997oXiqMk9I X-Received: by 2002:a17:906:16d2:: with SMTP id t18mr4058467ejd.277.1621507918436; Thu, 20 May 2021 03:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507918; cv=none; d=google.com; s=arc-20160816; b=btS0b1NmGKFUpy3ue+A3LiHrLzfMkF2P7I2lMLNxQSk+4udLRbQwPCBul5ieXv4Qum NK2H9QWZ6z3GIipQWDVK9ZPpE9wCb6NaNNAjN1aFW3I2RWYOIy7hZDz+fCfCdTefgFNU CRrcTg1RDbGvd9b13Wlp0rlS4z+r7RFtzl/3JS7gVa5WyV0QdZ7/HERQxJuNl/PYgSGx 4JJsBGAQ8kq0dpGkQTvL572U5rzXSorTuO43bzQkzHdnolr3x4/dWORHVnHBQQCR9GAJ S3R8W1oC0mgkERv0swn/FK62aYB04uBxRE8vkBv1vSZrHVaakjEjTH0nbWnQ38xIONu9 vBbw== 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=j8EBYMpzH3W5/xMaToLNol72UXcHK/JqWPp9YIaypx4jh1NO+Bh1UIDCwmrv5zo9PB D9i+ow+U/laDBi7PP1KbUzAoIQk29a08YH0ZR7e80wOEkk8Eb31JaOiUVRStluh1z/3X p/+7wJljP11uhtRDaeIMWTm+RnjN1HQ5GhDjA1qOug4bRRPgmxK2voiNVw4qzoN8SyQF r9AAdz7wV+cmgiqTJrBcq8+aFOIqPl7x6JqINqd21TnX9OkczxsqJP6CIBa+Tn9AHVNX Wyace2pIlG8U1aDPXNrJxH0PEXjquaw6O04c0E9oJXD3o2vfZXHAS2lwDpz6dPaBY8vo TyRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MMNnLL83; 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 q17si2511079ejj.672.2021.05.20.03.50.50; Thu, 20 May 2021 03:51:58 -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=MMNnLL83; 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 S238667AbhETKuH (ORCPT + 99 others); Thu, 20 May 2021 06:50:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237058AbhETKdm (ORCPT ); Thu, 20 May 2021 06:33:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A21361C53; Thu, 20 May 2021 09:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504385; bh=wc2f9ho+L9XPJcFs4VOnTopaVG8HjPKl2gTGzl3PhmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMNnLL83qfHllRkjQnWkh6Esjt9G3VCPcj3hTKwDYQ2qcGO2n0uS5hNiAbg2IPqGq kBjMePYV5UZ4wOf+qHXQY+wf8B2Xffxuflj8b++umUXUAwoyCiBZYyjm/4NJOGI9ZS qxgO2z8oJR4GQ90Xy1F8aGTh5tgR7UwjCg0VLZAQ= 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.14 221/323] RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Date: Thu, 20 May 2021 11:21:53 +0200 Message-Id: <20210520092127.710759502@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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