From patchwork Wed Jan 7 23:18:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 5588761 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B4BD89F443 for ; Wed, 7 Jan 2015 23:18:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC4ED20340 for ; Wed, 7 Jan 2015 23:18:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 713B3202FE for ; Wed, 7 Jan 2015 23:18:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755174AbbAGXSy (ORCPT ); Wed, 7 Jan 2015 18:18:54 -0500 Received: from gw03.mail.saunalahti.fi ([195.197.172.111]:40806 "EHLO gw03.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754579AbbAGXSy (ORCPT ); Wed, 7 Jan 2015 18:18:54 -0500 Received: from localhost.localdomain (a91-152-110-231.elisa-laajakaista.fi [91.152.110.231]) by gw03.mail.saunalahti.fi (Postfix) with ESMTP id 4EB5A20049; Thu, 8 Jan 2015 01:18:46 +0200 (EET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id t07NIkTv008448; Thu, 8 Jan 2015 01:18:46 +0200 Received: (from andy@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id t07NIg0r008446; Thu, 8 Jan 2015 01:18:42 +0200 X-Authentication-Warning: localhost.localdomain: andy set sender to andy.shevchenko@gmail.com using -f From: Andy Shevchenko To: Kalle Valo , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1] libertas: avoid potential null-pointer dereference Date: Thu, 8 Jan 2015 01:18:41 +0200 Message-Id: <1420672721-8400-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.8.3.101.g727a46b Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have to check pointer before dereferencing it. Reported-by: Andrey Karpov Signed-off-by: Andy Shevchenko --- drivers/net/wireless/libertas/cfg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 34f09ef..1d335e6 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -1109,7 +1109,7 @@ static int lbs_associate(struct lbs_private *priv, size_t len, resp_ie_len; int status; int ret; - u8 *pos = &(cmd->iebuf[0]); + u8 *pos; u8 *tmp; lbs_deb_enter(LBS_DEB_CFG80211); @@ -1138,6 +1138,8 @@ static int lbs_associate(struct lbs_private *priv, cmd->listeninterval = cpu_to_le16(MRVDRV_DEFAULT_LISTEN_INTERVAL); cmd->capability = cpu_to_le16(bss->capability); + pos = cmd->iebuf; + /* add SSID TLV */ rcu_read_lock(); ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);