From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934514AbdDSNel (ORCPT ); Wed, 19 Apr 2017 09:34:41 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45560 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934482AbdDSNei (ORCPT ); Wed, 19 Apr 2017 09:34:38 -0400 Subject: Re: [PATCH] ASoC: Intel: Skylake: fix dereference before NULL check on ebus To: Dan Carpenter References: <20170419121613.12353-1-colin.king@canonical.com> <20170419133249.ac3sdmn7kqjbxaii@mwanda> Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vinod Koul , Jeeja KP , Jayachandran B , "Subhransu S . Prusty" , Dharageswari R , Pardha Saradhi K , Yong Zhi , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org From: Colin Ian King Message-ID: Date: Wed, 19 Apr 2017 14:34:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170419133249.ac3sdmn7kqjbxaii@mwanda> 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 19/04/17 14:32, Dan Carpenter wrote: > On Wed, Apr 19, 2017 at 01:16:13PM +0100, Colin King wrote: >> From: Colin Ian King >> >> ebus is being NULL checked however it is being dereferenced >> earlier on the assignment bus = ebus_to_hbus(ebus). Fix this >> by moving the assignment to after the NULL check on ebus to >> avoid a NULL pointer dereference error. >> > > ebus_to_hbus() doesn't dereference "ebus" it just uses it for pointer > math. > > #define ebus_to_hbus(ebus) (&(ebus)->bus) > > If you pass a NULL to there, it returns an offset starting from NULL but > it doesn't Oops. Doh, brown paper bag moment for me. > > regards, > dan carpenter > >