From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753426AbdKKKXN (ORCPT ); Sat, 11 Nov 2017 05:23:13 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:46370 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751336AbdKKKXM (ORCPT ); Sat, 11 Nov 2017 05:23:12 -0500 Date: Sat, 11 Nov 2017 19:23:07 +0900 (KST) Message-Id: <20171111.192307.246949830866393163.davem@davemloft.net> To: aleksey.makarov@cavium.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sunil.Goutham@cavium.com, rric@kernel.org, sgoutham@cavium.com Subject: Re: [PATCH net-next] net: thunderx: fix double free error From: David Miller In-Reply-To: <20171109115859.23838-1-aleksey.makarov@cavium.com> References: <20171109115859.23838-1-aleksey.makarov@cavium.com> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 11 Nov 2017 02:23:11 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aleksey Makarov Date: Thu, 9 Nov 2017 14:58:57 +0300 > This patch fixes an error in memory allocation/freeing in > ThunderX PF driver. > > I moved the allocation to the probe() function and made it managed. > > From the Colin's email: > > While running static analysis on linux-next with CoverityScan I found 3 > double free errors in the Cavium thunder driver. > > The issue occurs on the err_disable_device: label of function nic_probe > when nic_free_lmacmem(nic) is called and a double free occurs on > nic->duplex, nic->link and nic->speed. This occurs when nic_init_hw() > fails: > > /* Initialize hardware */ > err = nic_init_hw(nic); > if (err) > goto err_release_regions; > > nic_init_hw() calls nic_get_hw_info() and this calls nic_free_lmacmem() > if any of the allocations fail. This free'ing occurs again by the call > to nic_free_lmacmem() on the err_release_regions exit path in nic_probe(). > > Reported-by: Colin Ian King > Signed-off-by: Aleksey Makarov Applied, thank you.