Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2653571imj; Mon, 11 Feb 2019 06:31:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IautVF7chxsoR5LWNbaOoFF/gZ3gGgelvFzY0+3iiGUhnrqyVsh+0cXph2QZAFj/UWgYoAW X-Received: by 2002:a63:1824:: with SMTP id y36mr34096999pgl.68.1549895485467; Mon, 11 Feb 2019 06:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895485; cv=none; d=google.com; s=arc-20160816; b=RdV9LYcs7LWoVQP/0vPuHo6101Vo88w0nZYY3nOLCdCeZqcCwy+Fd39lAYQAyzgPNw /TriMEdY0QGm6ZIgl3veFe/qD9u+AsL2fPHF0j/w9YYse+bonk2u+rOlnv9CeczAqxY5 gcOKiaU+F3YgnvGa/L3OY9HBJRQuxyKK7D9v5MyMuuQDLRTTcD3JezHKHZFu7W/TLL/H vOKc+KaFDX1T9Jftlm6LhvbU1jU5szbV9dXBmnvi3U5W6ELbuflrxc20T2YD56xLJcHU +QWuEDIdsJlmX7ZQVYq/t5Lq0L3ChDqdG6kvnLZ4FvbXWfjFoP9AATK9yxl0f7UqekWg 1elA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zcj1Uhsb8Eff7Qrxe7LGZ/YOtr6KsFllAs8aNhsKDx8=; b=wtzLFTp+q3raegDmyf0QXcEkOsmVZSQzS3/VdMHfDpMgCYmEdWXmNGM+6GQTH109AH PoDjdINOjelaugnZIUTOeLPaHhP5M2OrTJlty2wXzFhweGv8k/OrNH0PjtPFZmUSYYtE 7ejOApLCfNAUdfmc99PL+PpUwd5mBdCvilCEn7VLaPBBGZVYco45sYyknywg+b9tutCG sbKKSRh175QfGWX0Oxo6rUPlLGFHS5DHfoF5PbOKI+8zDYGegzosgGoQpq8lzAtfL2ar pvQtn6SHG4jYJIct+SywjgSC1OGqlx3qTP1/5pFjZbjM9Ch+Bl/Y4k7UR8r8KEP7kXC8 Zdqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y89LOjLG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si1545935plp.257.2019.02.11.06.31.09; Mon, 11 Feb 2019 06:31:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y89LOjLG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730168AbfBKOao (ORCPT + 99 others); Mon, 11 Feb 2019 09:30:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:37096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729012AbfBKOah (ORCPT ); Mon, 11 Feb 2019 09:30:37 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5396420675; Mon, 11 Feb 2019 14:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895436; bh=AVjOb0BPEAYeblgLmfRnxNpAq9oHPcIX5BzpRyHYHvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y89LOjLGiIyyvv725c6GYvalAtAjA9dzln4+BVK6gYgQ8/bi6BSDDrAu7SUVhBCJl I6emkJuVSmYfcUDiG8UhbQMDDvK1hq2sOgw9GeDfKnrPlNEAKEfy1R8O4jz0UxDjQY Y1Zm0CUq7EzGb86eFDZLMeQkp8TPHQPf3VXMhQpM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huazhong Tan , Peng Li , "David S. Miller" , Sasha Levin Subject: [PATCH 4.20 204/352] net: hns3: fix error handling int the hns3_get_vector_ring_chain Date: Mon, 11 Feb 2019 15:17:11 +0100 Message-Id: <20190211141900.125445339@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit cda69d244585bc4497d3bb878c22fe2b6ad647c1 ] When hns3_get_vector_ring_chain() failed in the hns3_nic_init_vector_data(), it should do the error handling instead of return directly. Also, cur_chain should be freed instead of chain and head->next should be set to NULL in error handling of hns3_get_vector_ring_chain. This patch fixes them. Fixes: 73b907a083b8 ("net: hns3: bugfix for buffer not free problem during resetting") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 20fcf0d1c2ce..4aea3f57586e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2783,9 +2783,10 @@ err_free_chain: cur_chain = head->next; while (cur_chain) { chain = cur_chain->next; - devm_kfree(&pdev->dev, chain); + devm_kfree(&pdev->dev, cur_chain); cur_chain = chain; } + head->next = NULL; return -ENOMEM; } @@ -2876,7 +2877,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) ret = hns3_get_vector_ring_chain(tqp_vector, &vector_ring_chain); if (ret) - return ret; + goto map_ring_fail; ret = h->ae_algo->ops->map_ring_to_vector(h, tqp_vector->vector_irq, &vector_ring_chain); -- 2.19.1