From patchwork Mon Apr 24 00:40:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 9695387 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 629D16037F for ; Mon, 24 Apr 2017 00:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5385D269A3 for ; Mon, 24 Apr 2017 00:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47F2526BE9; Mon, 24 Apr 2017 00:41:12 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 207D0269A3 for ; Mon, 24 Apr 2017 00:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163818AbdDXAks (ORCPT ); Sun, 23 Apr 2017 20:40:48 -0400 Received: from m12-11.163.com ([220.181.12.11]:60973 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163769AbdDXAko (ORCPT ); Sun, 23 Apr 2017 20:40:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=hOK2kkntAUOob1ZJrt cytDUxxuBm7VMFEgJDXmyymxA=; b=BVGaFxiB0NeilCLI0MJCZPBYpuMolBgwrE WpVI9MtXf/KTRuI04qV1XK+ObBxe+6bVqYbk14Fl+845zDGymGLTCMEej61sQTL8 s3LOHGztymNR4vvstYZ9avf/aJSfpHpHvQ7084bkq5wPVjnfTXmkRtPL0nxGaANu GL+cHpehE= Received: from localhost.localdomain (unknown [106.120.213.67]) by smtp7 (Coremail) with SMTP id C8CowAAnzip+Sf1Y2GwLAg--.46983S3; Mon, 24 Apr 2017 08:40:33 +0800 (CST) From: Pan Bian To: Jussi Kivilinna , Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] rndis_wlan: add return value validation Date: Mon, 24 Apr 2017 08:40:28 +0800 Message-Id: <1492994428-16090-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C8CowAAnzip+Sf1Y2GwLAg--.46983S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw1UKw1kKw1DJF1xuF45Wrg_yoWkKFX_WF WxXFn7WrWrGw1jgw40kr43ZryFkry5XFn5Za1jqrWYqr17AFWIqrs5ZF98XrsrW342qryx WFnFvF17A392qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5Bv35UUUUU== X-Originating-IP: [106.120.213.67] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/xtbBXhfC91aDqPgCGAACsh 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: Pan Bian Function create_singlethread_workqueue() will return a NULL pointer if there is no enough memory, and its return value should be validated before using. However, in function rndis_wlan_bind(), its return value is not checked. This may cause NULL dereference bugs. This patch fixes it. Signed-off-by: Pan Bian --- drivers/net/wireless/rndis_wlan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 785334f..92a1bde 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -3427,6 +3427,10 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf) /* because rndis_command() sleeps we need to use workqueue */ priv->workqueue = create_singlethread_workqueue("rndis_wlan"); + if (!priv->workqueue) { + wiphy_free(wiphy); + return -ENOMEM; + } INIT_WORK(&priv->work, rndis_wlan_worker); INIT_DELAYED_WORK(&priv->dev_poller_work, rndis_device_poller); INIT_DELAYED_WORK(&priv->scan_work, rndis_get_scan_results);