From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752672AbcEVVU0 (ORCPT ); Sun, 22 May 2016 17:20:26 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:41914 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbcEVVUZ (ORCPT ); Sun, 22 May 2016 17:20:25 -0400 Subject: Re: [PATCH] net/ethoc: fix null dereference on error exit path To: Max Filippov References: <1463944098-7061-1-git-send-email-colin.king@canonical.com> <20160522194228.GA11011@octofox.metropolis> Cc: "David S . Miller" , Andrew Lunn , Florian Fainelli , Tobias Klauser , netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Colin Ian King Message-ID: <57422295.4050007@canonical.com> Date: Sun, 22 May 2016 22:20:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160522194228.GA11011@octofox.metropolis> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/05/16 20:42, Max Filippov wrote: > Hi Colin, > > On Sun, May 22, 2016 at 08:08:18PM +0100, Colin King wrote: >> From: Colin Ian King >> >> priv is assigned to NULL however all the error exit paths to label 'free' >> dereference priv, causing a null pointer dereference. >> >> Examination of the code shows that all error exits via the 'free' >> label path occur before priv is assigned to netdev_priv(netdev), hence >> there is no need to call clk_disable_unprepare and so the location of >> the label should be moved to free_netdev statement to avoid this null >> dereference on priv. > > This description is a bit inaccurate. Indeed all 'goto free' above the > 'priv = netdev_priv(netdev);' need to skip 'if (priv->clk)' check, but > there are two more 'goto free' below that line, and they look correct > now, but after this patch they'll leave the clock enabled. > Oops, I'll resend a corrected fix tomorrow