From patchwork Wed May 3 11:48:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 9709499 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 349FC6021C for ; Wed, 3 May 2017 11:49:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214D728601 for ; Wed, 3 May 2017 11:49:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1481B28613; Wed, 3 May 2017 11:49:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B565E28601 for ; Wed, 3 May 2017 11:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbdECLtA (ORCPT ); Wed, 3 May 2017 07:49:00 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35849 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbdECLs6 (ORCPT ); Wed, 3 May 2017 07:48:58 -0400 Received: by mail-pf0-f194.google.com with SMTP id v14so3979891pfd.3 for ; Wed, 03 May 2017 04:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=deCzfCCUOTG3SzhDSe7JgHoyXUgdcRhP4cpaJEKxH3U=; b=kV7v+WAdZrNx0usg0uKHvWAcdDQ30BfDlg2iORAgQmd0EYsdhMKDkbncZj24mlRVRW 9yQp2ay9OQ3OVus8h3GaiWuEGuMc6I7LOtOsP5ep+u5DPgOU35vtPR7TWpML4+I+Y9M6 nVy/sbXEFCHmxZLcHg5Cy8cPmgyKLviaH55CM4NvaQSmK3agO46/v4GMBIb6bDPIdphN aaLQNaE5wlvyeahMtnmpCaKzB0Px+qEr33BL29hKiJUukJbWdcW9SmvrYc8ct1od4hmk kR3rVHg00relfWPg3qYpcbq/IWVGqEg0DWwpqB0Qvx5XDT4Jx+fkJ37K1Iew60UOUMgq lrjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=deCzfCCUOTG3SzhDSe7JgHoyXUgdcRhP4cpaJEKxH3U=; b=ZOY0qzOModeFU0xWp56xU61duHfipnoSStsNoXPydU8KqEsQWW25imO2ADWSeNRhym 6mWYLyJcJICKULZLARGd+TZlMKLlBzqM0PXxNxCJJ5B4srLIh6kW4D62Dq8TlkxpvHW0 3Jq6rtaAP2y0RHWBqE98GkLoA6YJhvpe1uATPCFWcQ+kGIrET5aqvZBY9EHTVocR5N3N Se3GLTOzvnPaJk+Mg1JPz4g7gF7iCpALlK8yaA92dK+aEcxY2on4rc01jdjPW09uksT+ Bg291xZO9BvVD2PQxncuFiS46gC1fOdnXlekSsS9O14t471Y3pd2t+djyzAhrMF5O1sH 8+8A== X-Gm-Message-State: AN3rC/54+BrwLgu8HJuYQBQnVv+ov+C1hBghhYnShfI1Ww8rsbuf+NE6 /oz3AnfoachNeg== X-Received: by 10.98.52.4 with SMTP id b4mr4575187pfa.124.1493812137045; Wed, 03 May 2017 04:48:57 -0700 (PDT) Received: from ubuntu.members.linode.com ([2400:8902::f03c:91ff:fee7:7cf1]) by smtp.gmail.com with ESMTPSA id f80sm4571976pff.84.2017.05.03.04.48.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 May 2017 04:48:56 -0700 (PDT) From: Xinming Hu To: Linux Wireless Cc: Kalle Valo , Brian Norris , Dmitry Torokhov , rajatja@google.com, Zhiyuan Yang , Cathy Luo , Xinming Hu Subject: [PATCH 2/6] mwifiex: usb: urb->context sanity check in complete handler Date: Wed, 3 May 2017 11:48:39 +0000 Message-Id: <1493812123-12053-2-git-send-email-huxinming820@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493812123-12053-1-git-send-email-huxinming820@gmail.com> References: <1493812123-12053-1-git-send-email-huxinming820@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xinming Hu urb/context might be freed in cornel case, add sanity check to avoid use-after-free. Signed-off-by: Xinming Hu --- drivers/net/wireless/marvell/mwifiex/usb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c index 2f7705c..ee5f488 100644 --- a/drivers/net/wireless/marvell/mwifiex/usb.c +++ b/drivers/net/wireless/marvell/mwifiex/usb.c @@ -169,6 +169,11 @@ static void mwifiex_usb_rx_complete(struct urb *urb) int recv_length = urb->actual_length; int size, status; + if (!urb || !urb->context) { + pr_err("URB or URB context is not valid in USB Rx complete\n"); + return; + } + if (!adapter || !adapter->card) { pr_err("mwifiex adapter or card structure is not valid\n"); return; @@ -260,6 +265,11 @@ static void mwifiex_usb_tx_complete(struct urb *urb) struct usb_tx_data_port *port; int i; + if (!urb || !urb->context) { + pr_err("URB or URB context is not valid in USB Tx complete\n"); + return; + } + mwifiex_dbg(adapter, INFO, "%s: status: %d\n", __func__, urb->status);