Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753570AbdHXSxo (ORCPT ); Thu, 24 Aug 2017 14:53:44 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:36825 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbdHXSxn (ORCPT ); Thu, 24 Aug 2017 14:53:43 -0400 Subject: Re: [PATCH] staging: r8822be: fix null pointer dereference with a null driver_adapter To: Colin King , Greg Kroah-Hartman , Ping-Ke Shih , devel@driverdev.osuosl.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170823150710.22313-1-colin.king@canonical.com> From: Larry Finger Message-ID: <78a07acc-cf73-551c-f9ef-eb9891bbdf50@lwfinger.net> Date: Thu, 24 Aug 2017 13:53:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170823150710.22313-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1892 Lines: 45 On 08/23/2017 10:07 AM, Colin King wrote: > From: Colin Ian King > > The call to _rtl_dbg_trace via macro HALMAC_RT_TRACE will trigger a null > pointer deference on the null driver_adapter. Fix this by assigning > driver_adapter earlier to halmac_adapter->driver_adapter before the tracing > call so that a non-null driver_adapter is passed instead. > > Detected by CoverityScan, CID#1454613 ("Explicit null dereferenced") > > Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-driver") > Signed-off-by: Colin Ian King Acked-by: Larry Finger Thanks, Larry > --- > drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c > index a6c8a87f755f..3a24e33228f8 100644 > --- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c > +++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c > @@ -4447,7 +4447,7 @@ halmac_func_p2pps_88xx(struct halmac_adapter *halmac_adapter, > { > u8 h2c_buff[HALMAC_H2C_CMD_SIZE_88XX] = {0}; > u16 h2c_seq_mum = 0; > - void *driver_adapter = NULL; > + void *driver_adapter = halmac_adapter->driver_adapter; > struct halmac_api *halmac_api; > struct halmac_h2c_header_info h2c_header_info; > enum halmac_ret_status status = HALMAC_RET_SUCCESS; > @@ -4455,7 +4455,6 @@ halmac_func_p2pps_88xx(struct halmac_adapter *halmac_adapter, > HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG, > "[TRACE]halmac_p2pps !!\n"); > > - driver_adapter = halmac_adapter->driver_adapter; > halmac_api = (struct halmac_api *)halmac_adapter->halmac_api; > > P2PPS_SET_OFFLOAD_EN(h2c_buff, p2p_ps->offload_en); >