Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp117543ybg; Mon, 8 Jun 2020 18:05:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhzLCo8WxJJBDKib3W2tTE+f8+yOwiSmEfn91atNNGjbaf4CnXUXtt3MsLLr9Mo9NHqqIU X-Received: by 2002:a17:906:c1c1:: with SMTP id bw1mr23958781ejb.379.1591664745199; Mon, 08 Jun 2020 18:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664745; cv=none; d=google.com; s=arc-20160816; b=IoH5JHzkAUIVutcBn7vE72Xv2+pXMuSRpFlRmr90nA3DcjXnkhP9H2NJ+NAfeHdjBl 9ONDu0MFVrCZUPHLVaSvBq0/muQaDNIpmanJtEQrh77ZP/iP0ymaMME+JxchiQyXmihe CVcdYgRlPki9rrxpQIaT+akWv/aPumcU4kKLuul3XMt6si0bnY0QJ+Ggpg/SuhagqJ4Q S7VF6ce2ImPnl1qZx9lBSQiBodNwxxx8dfsSLagYGCDKVrAXoSGaPsl102Vs2pinYwmw M5AcYlIdhvP9c0UkbImPwEE0LCZVygaitVOc8Ci8X02OD8OKvpiz5Ul07O/8WgwwH96Y Iclw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e38+yTpd+G2msRVA6bX/sLxdn0rWDQWWYOJc+U/NGvk=; b=I54MsH0C3eXj8A25KXC+0OHnM2u0bwU3HErvvF3UfYqHutFkrAoI3WuCNeR6tt0OnY Rc3opHUsj4srpNJNqAKq5Sj45m15oR1Brel/muqAWRMylzJvwz8JvDwrMMg+hN4cNc6u AtLeQYzCEo96qeME/Et96oXlAGbV61sBZWRUMFZod+9sFFLnCDQr9Za2KfRmkHqZ5xlB f4u1LxXlKJtUUz4VFVdHcQ3GEiojCKQSLcXnM6gOHVVtbZezZhCNB9AZECTtOEg2ldbE eb30pclg08nEyEvSSuZE7qjJ7Jblf/L0EIxyw+z/O4BRHUngTUd0P7XljsrLFKfkC3Tu 27ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uOcUicxb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si12087185ejc.258.2020.06.08.18.05.22; Mon, 08 Jun 2020 18:05:45 -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=@kernel.org header.s=default header.b=uOcUicxb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388147AbgFIBDT (ORCPT + 99 others); Mon, 8 Jun 2020 21:03:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:52208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727782AbgFHXHm (ORCPT ); Mon, 8 Jun 2020 19:07:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F168B20812; Mon, 8 Jun 2020 23:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657661; bh=OMuK4o8Ehu5BM1rbVHdg6XjAxzAvk11aTBSgHZG4xWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOcUicxbWPqUUYKN5PeJmbO32sBIZ4EjKJrjBK16ph77l9IRAWA8H2lpozGwwz1vE rf2EdE+GLXLMkje/ma1tZDiqtQ+76zRmYGr8XkNPjcj96Sf6WIcEgI667YjJOSQ/Ah yJuNbfZn9Wo/EaFw4MczkLXFRQLnWtESy1s4qPfo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Surabhi Boob , Tony Nguyen , Andrew Bowers , Jeff Kirsher , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 073/274] ice: Fix memory leak Date: Mon, 8 Jun 2020 19:02:46 -0400 Message-Id: <20200608230607.3361041-73-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Surabhi Boob [ Upstream commit 1aaef2bc4e0a5ce9e4dd86359e6a0bf52c6aa64f ] Handle memory leak on filter management initialization failure. Signed-off-by: Surabhi Boob Signed-off-by: Tony Nguyen Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c index 2c0d8fd3d5cd..09b374590ffc 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c @@ -322,6 +322,7 @@ ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse, static enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw) { struct ice_switch_info *sw; + enum ice_status status; hw->switch_info = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*hw->switch_info), GFP_KERNEL); @@ -332,7 +333,12 @@ static enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw) INIT_LIST_HEAD(&sw->vsi_list_map_head); - return ice_init_def_sw_recp(hw); + status = ice_init_def_sw_recp(hw); + if (status) { + devm_kfree(ice_hw_to_dev(hw), hw->switch_info); + return status; + } + return 0; } /** -- 2.25.1