From: Colin Ian King <colin.king@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Larry Finger <Larry.Finger@lwfinger.net>,
Himanshu Jha <himanshujha199640@gmail.com>,
Ping-Ke Shih <pkshih@realtek.com>,
devel@driverdev.osuosl.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix null pointer dereferences with a null driver_adapter
Date: Fri, 8 Sep 2017 14:54:39 +0100 [thread overview]
Message-ID: <c70ba946-f7bb-6e0f-9fbd-bb57d82ceac2@canonical.com> (raw)
In-Reply-To: <20170908135222.640-1-colin.king@canonical.com>
On 08/09/17 14:52, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The call to _rtl_dbg_trace via macro HALMAC_RT_TRACE will trigger a null
> pointer deference on a 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.
>
> I should have spotted these with an earlier patch I sent, but I overlooked
> these in the rather large CoverityScan logs.
>
> Detected by CoverityScan, CID#1454550, CID#1454554, CID#1454565,
> CID#1454591, CID#1454598 ("Explicit null dereferenced")
>
> Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> .../staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c | 4 ++--
> .../staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c | 13 +++++++------
> 2 files changed, 9 insertions(+), 8 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 5f84526cb5b5..edbf6af1c8b7 100644
> --- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
> +++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
> @@ -2901,11 +2901,11 @@ halmac_update_datapack_88xx(struct halmac_adapter *halmac_adapter,
> if (halmac_adapter->fw_version.h2c_version < 4)
> return HALMAC_RET_FW_NO_SUPPORT;
>
> + driver_adapter = halmac_adapter->driver_adapter;
> +
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "[TRACE]%s ==========>\n", __func__);
>
> - driver_adapter = halmac_adapter->driver_adapter;
> -
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "[TRACE]%s <==========\n", __func__);
>
> diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
> index f33024e4d853..544f638ed3ef 100644
> --- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
> +++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c
> @@ -1618,10 +1618,11 @@ halmac_send_h2c_set_pwr_mode_88xx(struct halmac_adapter *halmac_adapter,
> void *driver_adapter = NULL;
> enum halmac_ret_status status = HALMAC_RET_SUCCESS;
>
> + driver_adapter = halmac_adapter->driver_adapter;
> +
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "%s!!\n", __func__);
>
> - driver_adapter = halmac_adapter->driver_adapter;
> h2c_header = h2c_buff;
> h2c_cmd = h2c_header + HALMAC_H2C_CMD_HDR_SIZE_88XX;
>
> @@ -1713,10 +1714,11 @@ halmac_media_status_rpt_88xx(struct halmac_adapter *halmac_adapter, u8 op_mode,
> void *driver_adapter = NULL;
> enum halmac_ret_status status = HALMAC_RET_SUCCESS;
>
> + driver_adapter = halmac_adapter->driver_adapter;
> +
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "halmac_send_h2c_set_pwr_mode_88xx!!\n");
>
> - driver_adapter = halmac_adapter->driver_adapter;
> h2c_header = H2c_buff;
> h2c_cmd = h2c_header + HALMAC_H2C_CMD_HDR_SIZE_88XX;
>
> @@ -2143,10 +2145,11 @@ halmac_func_ctrl_ch_switch_88xx(struct halmac_adapter *halmac_adapter,
> enum halmac_cmd_process_status *process_status =
> &halmac_adapter->halmac_state.scan_state_set.process_status;
>
> + driver_adapter = halmac_adapter->driver_adapter;
> +
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "halmac_ctrl_ch_switch!!\n");
>
> - driver_adapter = halmac_adapter->driver_adapter;
> halmac_api = (struct halmac_api *)halmac_adapter->halmac_api;
>
> if (halmac_transition_scan_state_88xx(
> @@ -2276,15 +2279,13 @@ enum halmac_ret_status halmac_send_h2c_update_bcn_parse_info_88xx(
> {
> 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_h2c_header_info h2c_header_info;
> enum halmac_ret_status status = HALMAC_RET_SUCCESS;
>
> HALMAC_RT_TRACE(driver_adapter, HALMAC_MSG_H2C, DBG_DMESG,
> "%s!!\n", __func__);
>
> - driver_adapter = halmac_adapter->driver_adapter;
> -
> UPDATE_BEACON_PARSING_INFO_SET_FUNC_EN(h2c_buff, bcn_ie_info->func_en);
> UPDATE_BEACON_PARSING_INFO_SET_SIZE_TH(h2c_buff, bcn_ie_info->size_th);
> UPDATE_BEACON_PARSING_INFO_SET_TIMEOUT(h2c_buff, bcn_ie_info->timeout);
>
Oops, I messed up the subject line, will resend V2.
prev parent reply other threads:[~2017-09-08 13:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 13:52 Colin King
2017-09-08 13:54 ` Colin Ian King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c70ba946-f7bb-6e0f-9fbd-bb57d82ceac2@canonical.com \
--to=colin.king@canonical.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=himanshujha199640@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pkshih@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®