From patchwork Thu Mar 17 18:02:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 8613771 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 C0E179F3D1 for ; Thu, 17 Mar 2016 18:03:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE99220120 for ; Thu, 17 Mar 2016 18:03:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8D1F200BE for ; Thu, 17 Mar 2016 18:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967396AbcCQSDG (ORCPT ); Thu, 17 Mar 2016 14:03:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34471 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030824AbcCQSCu (ORCPT ); Thu, 17 Mar 2016 14:02:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EAE7F7F085; Thu, 17 Mar 2016 18:02:49 +0000 (UTC) Received: from ultrasam.trained-monkey.org (dhcp-10-15-49-144.lga.redhat.com [10.15.49.144]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HI2nMG018851; Thu, 17 Mar 2016 14:02:49 -0400 Received: from carbonite.redhat.com (localhost.localdomain [127.0.0.1]) by ultrasam.trained-monkey.org (Postfix) with ESMTP id 6844119413CF7; Thu, 17 Mar 2016 14:02:49 -0400 (EDT) From: Jes Sorensen To: Xose Vazquez Perez Cc: linux-wireless Subject: Re: rtl8xxxu 4.4.5(from f23): I get a panic adding a new device to the driver References: <56E89DD2.7000000@gmail.com> Date: Thu, 17 Mar 2016 14:02:49 -0400 In-Reply-To: (Jes Sorensen's message of "Wed, 16 Mar 2016 09:58:28 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Jes Sorensen writes: > Xose Vazquez Perez writes: >> Hi, >> >> If I do: >> # echo "0bda 8176" > /sys/bus/usb/drivers/rtl8xxxu/new_id > > Hi Xose, > > Yes please don't do that. The rtl8xxxu driver relies on the .driver_info > field in struct use_device_id to carry information for the different > types of devices. If you hot add a device like above, the driver will > fail because that field now contains a NULL pointer. > > I should probably add a check for it in the probe function, but it will > simply be there to spit out a warning that it doesn't work to hot add a > device like this. > > If you build it with CONFIG_RTL8XXXU_UNTESTED the 0bda:8176 should be > included in the device list. > > Cheers, > Jes Hi Xose, I added the following patch to my tree to avoid this. Cheers, Jes commit 9202f4947aac1d60084ee79c9b5294eb42ba59dc Author: Jes Sorensen Date: Thu Mar 17 13:53:48 2016 -0400 rtl8xxxu: Fix OOPS if user tries to add device via /sys This driver relies on driver_info in struct usb_device_id, hence adding a device via /sys/bus/usb/drivers/rtl8xxxu/new_id would result in a NULL pointer dereference. Instead print a message and return -ENODEV Reported-by: Xose Vazquez Perez Signed-off-by: Jes Sorensen --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c index 8d893f4..55fc00e 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c @@ -9671,6 +9671,15 @@ static int rtl8xxxu_probe(struct usb_interface *interface, udev = usb_get_dev(interface_to_usbdev(interface)); + if (!id->driver_info) { + dev_warn(&udev->dev, + "rtl8xxxu relies on driver_info in struct usb_device_id.\n"); + dev_warn(&udev->dev, + "Adding a device via /sys/bus/usb/drivers/rtl8xxxu/new_id is not supported!\n"); + ret = -ENODEV; + goto exit; + } + switch (id->idVendor) { case USB_VENDOR_ID_REALTEK: switch(id->idProduct) {