Commit Graph

279 Commits

Author SHA1 Message Date
Desnes Nunes 07ac0d6d6f USB: make single lock for all usb dynamic id lists
JIRA: https://issues.redhat.com/browse/RHEL-78828

commit 0b3144da31f855fce652303f588416a60991bdef
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Wed, 13 Nov 2024 07:49:22 +0100

  There are a number of places where we accidentally pass in a constant
  structure to later cast it off to a dynamic one, and then attempt to
  grab a lock on it, which is not a good idea.  To help resolve this, move
  the dynamic id lock out of the dynamic id structure for the driver and
  into one single lock for all USB dynamic ids.  As this lock should never
  have any real contention (it's only every accessed when a device is
  added or removed, which is always serialized) there should not be any
  difference except for some memory savings.

  Note, this just converts the existing use of the dynamic id lock to the
  new static lock, there is one place that is accessing the dynamic id
  list without grabbing the lock, that will be fixed up in a follow-on
  change.

  Cc: Johan Hovold <johan@kernel.org>
  Cc: Herve Codina <herve.codina@bootlin.com>
  Cc: Rob Herring <robh@kernel.org>
  Cc: Alan Stern <stern@rowland.harvard.edu>
  Cc: Grant Grundler <grundler@chromium.org>
  Cc: Oliver Neukum <oneukum@suse.com>
  Cc: Yajun Deng <yajun.deng@linux.dev>
  Cc: Douglas Anderson <dianders@chromium.org>
  Cc: linux-usb@vger.kernel.org
  Link: https://lore.kernel.org/r/2024111322-kindly-finalist-d247@gregkh
  Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2025-03-19 21:24:05 -03:00
Desnes Nunes b06d6e0355 USB: serial: set driver owner when registering drivers
JIRA: https://issues.redhat.com/browse/RHEL-59052

commit af8a6e65f42c6c89414017cc4d78403e83056172
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date: Fri, 3 May 2024 12:10:52 +0200

  Modules registering drivers with usb_serial_register_drivers() might
  forget to set .owner field.  The field is used by some of other kernel
  parts for reference counting (try_module_get()), so it is expected that
  drivers will set it.

  Solve the problem by moving this task away from the drivers to the core
  USB serial code, just like we did for platform_driver in
  commit 9447057eaf ("platform_device: use a macro instead of
  platform_driver_register").

  Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
  [ johan: amend commit summary ]
  Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2024-12-13 11:26:35 -03:00
Desnes Nunes ee61a2e6f7 USB: core: Use device_driver directly in struct usb_driver and usb_device_driver
JIRA: https://issues.redhat.com/browse/RHEL-34114

commit 49a78b05d5ca1e23fd737747a8757b8bdc319b30
Author: Yajun Deng <yajun.deng@linux.dev>
Date: Thu, 4 Jan 2024 11:28:22 +0800

  There is usbdrv_wrap in struct usb_driver and usb_device_driver, it
  contains device_driver and for_devices. for_devices is used to
  distinguish between device drivers and interface drivers.

  Like the is_usb_device(), it tests the type of the device. We can test
  that if the probe of device_driver is equal to usb_probe_device in
  is_usb_device_driver(), and then the struct usbdrv_wrap is no longer
  needed.

  Clean up struct usbdrv_wrap, use device_driver directly in struct
  usb_driver and usb_device_driver. This makes the code cleaner.

  Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
  Acked-by: Alan Stern <stern@rowland.harvard.edu>
  Link: https://lore.kernel.org/r/20240104032822.1896596-1-yajun.deng@linux.dev
  Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2024-05-29 16:29:57 -03:00
Andrew Halaney a56a61b376 tty: make tty_operations::write()'s count size_t
JIRA: https://issues.redhat.com/browse/RHEL-24205
Conflicts: tty3270 changes had to be applied by hand due
           to driver being out of date in cs9.

commit 95713967ba52389f7cea75704d0cf048080ec218
Author: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Date:   Thu Aug 10 11:15:03 2023 +0200

    tty: make tty_operations::write()'s count size_t

    Unify with the rest of the code. Use size_t for counts and ssize_t for
    retval.

    Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
    Link: https://lore.kernel.org/r/20230810091510.13006-30-jirislaby@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:57 -04:00
Andrew Halaney 269e4d489d tty: propagate u8 data to tty_operations::write()
JIRA: https://issues.redhat.com/browse/RHEL-24205
Conflicts: tty3270 changes had to be applied by hand due
           to driver being out of date in cs9.

commit 69851e4ab8feeb369119a44ddca430c0ee15f0d8
Author: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Date:   Thu Aug 10 11:15:01 2023 +0200

    tty: propagate u8 data to tty_operations::write()

    Data are now typed as u8. Propagate this change to
    tty_operations::write().

    Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
    Cc: Richard Henderson <richard.henderson@linaro.org>
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Cc: Matt Turner <mattst88@gmail.com>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
    Cc: Johannes Berg <johannes@sipsolutions.net>
    Cc: Chris Zankel <chris@zankel.net>
    Cc: Max Filippov <jcmvbkbc@gmail.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Vaibhav Gupta <vaibhavgupta40@gmail.com>
    Cc: Jens Taprogge <jens.taprogge@taprogge.org>
    Cc: Karsten Keil <isdn@linux-pingi.de>
    Cc: Scott Branden <scott.branden@broadcom.com>
    Cc: Ulf Hansson <ulf.hansson@linaro.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Alexander Gordeev <agordeev@linux.ibm.com>
    Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
    Cc: Sven Schnelle <svens@linux.ibm.com>
    Cc: David Lin <dtwlin@gmail.com>
    Cc: Johan Hovold <johan@kernel.org>
    Cc: Alex Elder <elder@kernel.org>
    Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: David Sterba <dsterba@suse.com>
    Cc: Shawn Guo <shawnguo@kernel.org>
    Cc: Sascha Hauer <s.hauer@pengutronix.de>
    Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
    Cc: Fabio Estevam <festevam@gmail.com>
    Cc: NXP Linux Team <linux-imx@nxp.com>
    Cc: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
    Cc: Oliver Neukum <oneukum@suse.com>
    Cc: Mathias Nyman <mathias.nyman@intel.com>
    Cc: Marcel Holtmann <marcel@holtmann.org>
    Cc: Johan Hedberg <johan.hedberg@gmail.com>
    Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
    Link: https://lore.kernel.org/r/20230810091510.13006-28-jirislaby@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:57 -04:00
Andrew Halaney 1160555197 tty: Convert ->dtr_rts() to take bool argument
JIRA: https://issues.redhat.com/browse/RHEL-24205

commit 5d420399073770134d2b03e004b2c0201c7fa26f
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Tue Jan 17 11:03:53 2023 +0200

    tty: Convert ->dtr_rts() to take bool argument

    Convert the raise/on parameter in ->dtr_rts() to bool through the
    callchain. The parameter is used like bool. In USB serial, there
    remains a few implicit bool -> larger type conversions because some
    devices use u8 in their control messages.

    In moxa_tiocmget(), dtr variable was reused for line status which
    requires int so use a separate variable for status.

    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20230117090358.4796-8-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:29 -04:00
Andrew Halaney 3c18eeb3a9 tty: Convert ->carrier_raised() and callchains to bool
JIRA: https://issues.redhat.com/browse/RHEL-24205

commit b300fb26c59a749bf49559932fa8a85eb916b5a7
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Tue Jan 17 11:03:52 2023 +0200

    tty: Convert ->carrier_raised() and callchains to bool

    Return boolean from ->carrier_raised() instead of 0 and 1. Make the
    return type change also to tty_port_carrier_raised() that makes the
    ->carrier_raised() call (+ cd variable in moxa into which its return
    value is stored).

    Also cleans up a few unnecessary constructs related to this change:

            return xx ? 1 : 0;
            -> return xx;

            if (xx)
                    return 1;
            return 0;
            -> return xx;

    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20230117090358.4796-7-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:29 -04:00
Andrew Halaney f03616d42b tty: Make ->set_termios() old ktermios const
JIRA: https://issues.redhat.com/browse/RHEL-24205

commit a8c11c1520347be74b02312d10ef686b01b525f1
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Tue Aug 16 14:57:39 2022 +0300

    tty: Make ->set_termios() old ktermios const

    There should be no reason to adjust old ktermios which is going to get
    discarded anyway.

    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220816115739.10928-9-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:25:05 -04:00
Andrew Halaney 8811d387ee tty: drop put_tty_driver
JIRA: https://issues.redhat.com/browse/RHEL-24205
Conflicts: Minor context diffs, the replacement of put_tty_driver()
           with tty_driver_kref_put() doesn't depend on any of the
           context diffs to be correct.

commit 9f90a4ddef4e4d3aa4229f6b117d4e57231457b3
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Fri Jul 23 09:43:16 2021 +0200

    tty: drop put_tty_driver

    put_tty_driver() is an alias for tty_driver_kref_put(). There is no need
    for two exported identical functions, therefore switch all users of
    old put_tty_driver() to new tty_driver_kref_put() and remove the former
    for good.

    Cc: Richard Henderson <rth@twiddle.net>
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Cc: Matt Turner <mattst88@gmail.com>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: Jeff Dike <jdike@addtoit.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
    Cc: Chris Zankel <chris@zankel.net>
    Cc: Max Filippov <jcmvbkbc@gmail.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
    Cc: Jens Taprogge <jens.taprogge@taprogge.org>
    Cc: Karsten Keil <isdn@linux-pingi.de>
    Cc: Scott Branden <scott.branden@broadcom.com>
    Cc: Ulf Hansson <ulf.hansson@linaro.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: David Lin <dtwlin@gmail.com>
    Cc: Johan Hovold <johan@kernel.org>
    Cc: Alex Elder <elder@kernel.org>
    Cc: Jiri Slaby <jirislaby@kernel.org>
    Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: David Sterba <dsterba@suse.com>
    Cc: Shawn Guo <shawnguo@kernel.org>
    Cc: Sascha Hauer <s.hauer@pengutronix.de>
    Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
    Cc: Fabio Estevam <festevam@gmail.com>
    Cc: NXP Linux Team <linux-imx@nxp.com>
    Cc: Oliver Neukum <oneukum@suse.com>
    Cc: Felipe Balbi <balbi@kernel.org>
    Cc: Mathias Nyman <mathias.nyman@intel.com>
    Cc: Marcel Holtmann <marcel@holtmann.org>
    Cc: Johan Hedberg <johan.hedberg@gmail.com>
    Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
    Acked-by: Alex Elder <elder@linaro.org>
    Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
    Acked-by: Max Filippov <jcmvbkbc@gmail.com>
    Acked-by: David Sterba <dsterba@suse.com>
    Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20210723074317.32690-8-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
2024-05-09 11:24:13 -04:00
Wander Lairson Costa 6bda6cbd4a
tty: stop using alloc_tty_driver
JIRA: https://issues.redhat.com/browse/RHEL-19959
CVE: CVE-2023-6546

Conflicts: drop the xtensa hunks as we don't support this architecture.

commit 39b7b42be4a82f036c392abc71724b4b7752ac03
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Fri Jul 23 09:43:13 2021 +0200

    tty: stop using alloc_tty_driver

    alloc_tty_driver was deprecated by tty_alloc_driver in commit
    7f0bc6a68e (TTY: pass flags to alloc_tty_driver) in 2012.

    I never got into eliminating alloc_tty_driver until now. So we still
    have two functions for allocating drivers which might be confusing. So
    get rid of alloc_tty_driver uses to eliminate it for good in the next
    patch.

    Note we need to switch return value checking as tty_alloc_driver uses
    ERR_PTR. And flags are now a parameter of tty_alloc_driver.

    Cc: Richard Henderson <rth@twiddle.net>(odd fixer:ALPHA PORT)
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Cc: Matt Turner <mattst88@gmail.com>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Jeff Dike <jdike@addtoit.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
    Cc: Chris Zankel <chris@zankel.net>
    Cc: Max Filippov <jcmvbkbc@gmail.com>
    Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
    Cc: Jens Taprogge <jens.taprogge@taprogge.org>
    Cc: Karsten Keil <isdn@linux-pingi.de>
    Cc: Ulf Hansson <ulf.hansson@linaro.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: David Sterba <dsterba@suse.com>
    Cc: Shawn Guo <shawnguo@kernel.org>
    Cc: Sascha Hauer <s.hauer@pengutronix.de>
    Cc: Oliver Neukum <oneukum@suse.com>
    Cc: Felipe Balbi <balbi@kernel.org>
    Cc: Johan Hovold <johan@kernel.org>
    Cc: Marcel Holtmann <marcel@holtmann.org>
    Cc: Johan Hedberg <johan.hedberg@gmail.com>
    Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
    Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
    Acked-by: Max Filippov <jcmvbkbc@gmail.com>
    Acked-by: David Sterba <dsterba@suse.com>
    Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20210723074317.32690-5-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
2024-01-24 12:00:11 -03:00
Desnes Nunes 0a718eccfe USB: serial: report unsupported break signalling
JIRA: https://issues.redhat.com/browse/RHEL-15948

commit c9d934053d9e850bc901b6425eacb5fe3d4b1738
Author: Johan Hovold <johan@kernel.org>
Date: Sun, 4 Jun 2023 14:35:05 +0200

  Instead of returning success when a driver does not support break
  signalling, return an error to let user space know and to avoid waiting
  when break is not supported.

  Tested-by: Corey Minyard <cminyard@mvista.com>
  Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2023-11-21 15:32:47 -03:00
Desnes Nunes f855eb3fef USB: serial: return errors from break handling
JIRA: https://issues.redhat.com/browse/RHEL-15948
Conflicts:
* Avoiding commit <f6d47fe5921a> ("usb: serial: Make ->set_termios() old
  ktermios const")

commit 6ff58ae17fd9523246a260434133ed9ab7f56df2
Author: Johan Hovold <johan@kernel.org>
Date: Sun, 4 Jun 2023 14:35:03 +0200

  Start propagating errors to user space when setting the break state
  fails.

  This will be used by follow-on changes to also report when a driver or
  device does not support break control.

  Tested-by: Corey Minyard <cminyard@mvista.com>
  Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2023-11-21 15:32:47 -03:00
Torez Smith bdcda55e62 USB: serial: fix tty-port initialized comments
Bugzilla: http://bugzilla.redhat.com/2113003
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=48723298
Tested: HP ZBook 15 G5/80D5 Laptop
  ThinkPad P1 Gen5  TB4
  HP zBook Fury

commit 688ee1d1785c1359f9040f615dd8e6054962bce2
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Jul 25 10:44:57 2022 +0200

    USB: serial: fix tty-port initialized comments

    Fix up the tty-port initialized comments which got truncated and
    obfuscated when replacing the old ASYNCB_INITIALIZED flag.

    Fixes: d41861ca19 ("tty: Replace ASYNC_INITIALIZED bit and update atomically")
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-11-01 22:28:56 -04:00
Torez Smith 08601c512f USB: serial: allow hung up ports to be suspended
Bugzilla: http://bugzilla.redhat.com/2061784
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45014530
Tested: HP ZBook 15 G5/80D5 Laptop
 TGL-U(QS) Laptop

commit 6400b974910407cd299dc08578a6c1792b4c922a
Author: Johan Hovold <johan@kernel.org>
Date:   Fri Sep 10 14:11:28 2021 +0200

    USB: serial: allow hung up ports to be suspended

    User space can keep a tty open indefinitely and that should not prevent
    a hung up port and its USB device from being runtime suspended.

    Fix this by incrementing the PM usage counter when the port it activated
    and decrementing the counter when the port is shutdown rather than when
    the tty is installed and the last reference is dropped, respectively.

    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-05-02 15:29:29 -04:00
Torez Smith d905423b1e USB: serial: clean up core error labels
Bugzilla: http://bugzilla.redhat.com/2061784
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45014530
Tested: HP ZBook 15 G5/80D5 Laptop
 TGL-U(QS) Laptop

Conflicts: Adjust lines for fuzz.

commit 96a83c95c3da5ba55ea2cf6ce87de10fc03417a9
Author: Johan Hovold <johan@kernel.org>
Date:   Fri Sep 10 14:11:27 2021 +0200

    USB: serial: clean up core error labels

    Clean up the core error labels by consistently naming them after what
    they do rather than after from where they are jumped to.

    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-05-02 15:29:29 -04:00
Jiri Slaby fff4ef17a9 tty: make tty_operations::chars_in_buffer return uint
tty_operations::chars_in_buffer is another hook which is expected to
return values >= 0. So make it explicit by the return type too -- use
unsigned int.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: David Sterba <dsterba@suse.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20210505091928.22010-27-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-13 18:29:11 +02:00
Jiri Slaby 03b3b1a240 tty: make tty_operations::write_room return uint
Line disciplines expect a positive value or zero returned from
tty->ops->write_room (invoked by tty_write_room). So make this
assumption explicit by using unsigned int as a return value. Both of
tty->ops->write_room and tty_write_room.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Acked-by: Alex Elder <elder@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com> # xtensa
Acked-by: David Sterba <dsterba@suse.com>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Chris Zankel <chris@zankel.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20210505091928.22010-23-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-13 17:03:20 +02:00
Johan Hovold 07125072b0 USB: serial: do not use tty class device for debugging
Use the port struct device rather than tty class device for debugging.

Note that while USB serial doesn't support serdev yet (due to serdev not
handling hotplugging), serdev ttys do not have a corresponding class
device and would have been logged using a "(NULL device *):" prefix.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-09 17:55:21 +02:00
Johan Hovold 01fd45f676 USB: serial: add generic support for TIOCSSERIAL
TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The closing_wait parameter determines how long to wait for the transfer
buffers to drain during close and the default timeout of 30 seconds may
not be sufficient at low line speeds. In other cases, when for example
flow is stopped, the default timeout may instead be too long.

Add generic support for TIOCSSERIAL and TIOCGSERIAL with handling of the
three common parameters close_delay, closing_wait and line for the
benefit of all USB serial drivers while still allowing drivers to
implement further functionality through the existing callbacks.

This currently includes a few drivers that report their base baud clock
rate even if that is really only of interest when setting custom
divisors through the deprecated ASYNC_SPD_CUST interface; an interface
which only the FTDI driver actually implements.

Some drivers have also been reporting back a fake UART type, something
which should no longer be needed and will be dropped by a follow-on
patch.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:02 +02:00
Johan Hovold 5f92aee93a USB: serial: fix return value for unsupported ioctls
Drivers should return -ENOTTY ("Inappropriate I/O control operation")
when an ioctl isn't supported, while -EINVAL is used for invalid
arguments.

Fix up the TIOCMGET, TIOCMSET and TIOCGICOUNT helpers which returned
-EINVAL when a USB serial driver did not implement the corresponding
methods.

Note that the TIOCMGET and TIOCMSET helpers predate git and do not get a
corresponding Fixes tag below.

Fixes: d281da7ff6 ("tty: Make tiocgicount a handler")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:01 +02:00
Johan Hovold 5de03c9969 USB: serial: add support for multi-interface functions
A single USB function can be implemented using a group of interfaces and
this is for example commonly used for Communication Class devices.

Add support for multi-interface functions to USB serial core and export
an interface that allows drivers to claim a second sibling interface.
The interface could easily be extended to allow claiming further
interfaces if ever needed.

When a driver claims a sibling interface in probe(), core allocates
resources for any bulk in, bulk out, interrupt in and interrupt out
endpoints found also on the sibling interface.

Disconnect is implemented so that unbinding either interface will
release the other interface while disconnect() is called precisely once.

Similarly, suspend() is called when the first sibling interface is
suspended and resume() is called when the last sibling interface is
resumed by USB core.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-01 10:04:07 +02:00
Johan Hovold b3431093ad USB: serial: refactor endpoint classification
Refactor endpoint classification and replace the build-time
endpoint-array sanity checks with runtime checks in preparation for
handling endpoints from a sibling interface.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-01 10:04:00 +02:00
Johan Hovold 53366a9f91 USB: serial: drop unused suspending flag
The suspending flag was added back in 2009 but no users ever followed.
Remove it.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-01 10:03:45 +02:00
Johan Hovold 615e58ccfb USB: serial: fix tty cleanup-op kernel-doc
The tty cleanup operation is called with a struct tty as its sole
parameter.

Signed-off-by: Johan Hovold <johan@kernel.org>
2020-03-11 09:39:01 +01:00
Johan Hovold fdb838efa3 USB: serial: suppress driver bind attributes
USB-serial drivers must not be unbound from their ports before the
corresponding USB driver is unbound from the parent interface so
suppress the bind and unbind attributes.

Unbinding a serial driver while it's port is open is a sure way to
trigger a crash as any driver state is released on unbind while port
hangup is handled on the parent USB interface level. Drivers for
multiport devices where ports share a resource such as an interrupt
endpoint also generally cannot handle individual ports going away.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-01-17 11:11:26 +01:00
Johan Hovold d51bdb93ca USB: serial: fix runtime PM after driver unbind
Since commit c2b71462d2 ("USB: core: Fix bug caused by duplicate
interface PM usage counter") USB drivers must always balance their
runtime PM gets and puts, including when the driver has already been
unbound from the interface.

Leaving the interface with a positive PM usage counter would prevent a
later bound driver from suspending the device.

Fixes: c2b71462d2 ("USB: core: Fix bug caused by duplicate interface PM usage counter")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191001084908.2003-4-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-04 14:38:46 +02:00
Mauro Carvalho Chehab ecefae6db0 docs: usb: rename files to .rst and add them to drivers-api
While there are a mix of things here, most of the stuff
were written from Kernel developer's PoV. So, add them to
the driver-api book.

A follow up for this patch would be to move documents from
there that are specific to sysadmins, adding them to the
admin-guide.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-20 14:28:36 +02:00
Johan Hovold 579bebe5dd USB: serial: fix initial-termios handling
The USB-serial driver init_termios callback is used to override the
default initial terminal settings provided by USB-serial core.

After a bug was fixed in the original implementation introduced by
commit fe1ae7fdd2 ("tty: USB serial termios bits"), the init_termios
callback was no longer called just once on first use as intended but
rather on every (first) open.

This specifically meant that the terminal settings saved on (final)
close were ignored when reopening a port for drivers overriding the
initial settings.

Also update the outdated function header referring to the creation of
termios objects.

Fixes: 7e29bb4b77 ("usb-serial: fix termios initialization logic")
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-04-26 08:37:53 +02:00
Al Viro 930236a308 complete ->[sg]et_serial() switchover
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:43 -04:00
Al Viro 81732b26e0 usb-serial: begin switching to ->[sg]et_serial()
add such methods for usb_serial_driver, provide tty_operations
->[sg]et_serial() calling those.  For now the lack of methods
in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(),
making tty_ioctl() fall back to calling ->ioctl().  Once all
drivers are converted, we'll be returning -ENOTTY instead,
completing the switchover.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:34 -04:00
Linus Torvalds 07c4dd3435 USB/PHY patches for 4.18-rc1
Here is the big USB pull request for 4.18-rc1.
 
 Lots of stuff here, the highlights are:
 	- phy driver updates and new additions
 	- usual set of xhci driver updates
 	- normal set of musb updates
 	- gadget driver updates and new controllers
 	- typec work, it's getting closer to getting fully out of the
 	  staging portion of the tree.
 	- lots of minor cleanups and bugfixes.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWxba6w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykumQCg2abWE5LijR0SNJIwX8xk64HLUAMAnAxBZDG3
 aB0GyOQd54L+09q4LAdn
 =ZCEx
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB and PHY updates from Greg KH:
 "Here is the big USB pull request for 4.18-rc1.

  Lots of stuff here, the highlights are:

   - phy driver updates and new additions

   - usual set of xhci driver updates

   - normal set of musb updates

   - gadget driver updates and new controllers

   - typec work, it's getting closer to getting fully out of the staging
     portion of the tree.

   - lots of minor cleanups and bugfixes.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA issue"
  xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers
  xhci: Allow more than 32 quirks
  usb: xhci: force all memory allocations to node
  selftests: add test for USB over IP driver
  USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
  USB: gadget: udc: s3c2410_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: renesas_usb3: no need to check return value of debugfs_create functions
  USB: gadget: udc: pxa27x_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: gr_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: bcm63xx_udc: no need to check return value of debugfs_create functions
  USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions
  USB: dwc3: no need to check return value of debugfs_create functions
  USB: dwc2: no need to check return value of debugfs_create functions
  USB: core: no need to check return value of debugfs_create functions
  USB: chipidea: no need to check return value of debugfs_create functions
  USB: ehci-hcd: no need to check return value of debugfs_create functions
  USB: fhci-hcd: no need to check return value of debugfs_create functions
  USB: fotg210-hcd: no need to check return value of debugfs_create functions
  USB: imx21-hcd: no need to check return value of debugfs_create functions
  ...
2018-06-05 16:14:12 -07:00
Johan Hovold 79ef51894a USB: serial: use tty_port_register_device()
We already have the tty port when probing a usb-serial port so use
tty_port_register_device() directly instead of tty_port_install() later
to set up the port link.

This is a step towards enabling serdev for usb-serial (but we need to
determine how to handle hotplugging first).

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-17 11:22:00 +02:00
Christoph Hellwig 8a8dcabffb tty: replace ->proc_fops with ->proc_show
Just set up the show callback in the tty_operations, and use
proc_create_single_data to create the file without additional
boilerplace code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-16 07:24:30 +02:00
Johan Hovold 627cfa89b1 USB: serial: fix module-license macros
Several GPL-2.0 drivers used "GPL" rather than "GPL v2" in their
MODULE_LICENSE macros; fix the macros to match the licenses.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-04 11:58:00 +01:00
Greg Kroah-Hartman 6ca98bc284 USB: serial: Remove redundant license text
Now that the SPDX tag is in all USB files, that identifies the license
in a specific and legally-defined manner.  So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-04 11:55:38 +01:00
Greg Kroah-Hartman 5fd54ace47 USB: add SPDX identifiers to all remaining files in drivers/usb/
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/usb/ and include/linux/usb* files with the correct
SPDX license identifier based on the license text in the file itself.
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-04 11:48:02 +01:00
Johan Hovold 2944fd27d1 USB: serial: drop unused core USB driver
Drop the usb-serial-core USB driver that was registered at module init
but then never used.

This was a remnant dating back to 2004 (!) when this struct usb_driver
was used for the generic driver; see commit bbc53b7d7322 ("USB: fix bug
where removing usb-serial modules or usb serial devices could oops") in
the tglx bitkeeper-history archive.

Note that every usb-serial driver (including the generic one) registers
its own USB (interface) driver along with its usb-serial bus drivers.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-13 09:48:55 +02:00
Johan Hovold c22ac6d29f USB: serial: propagate late probe errors
Propagate errnos for late probe errors (e.g. -ENOMEM on allocation
failures) instead of always returning -EIO.

Note that some drivers are currently returning -ENODEV from their attach
callbacks when a device is not supported, but this has also been mapped
to -EIO.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-21 09:40:07 +02:00
Johan Hovold 45e5d4d418 USB: serial: refactor port endpoint setup
Make the probe callback more readable by refactoring the port
endpoint-resource setup by adding four helper functions.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-21 09:38:58 +02:00
Johan Hovold e1fdd5b262 USB: serial: drop obsolete open-race workaround
Commit a65a6f14dc ("USB: serial: fix race between probe and open")
fixed a race between probe and open, which could lead to crashes when a
not yet fully initialised port was being opened.

This race was later incidentally closed by commit 7e73eca6a7 ("TTY:
move cdev_add to tty_register_device") which moved character-device
registration from tty_register_driver to tty_register_device, which
isn't called until the port has been fully set up.

Remove the now redundant workaround which had the negative side effect
of not allowing a port to be opened immediately after user space had
been notified of a new tty device.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-31 13:14:39 +02:00
Johan Hovold 9fda620a5f USB: serial: move pl2303 hack out of usb-serial core
Some pl2303 devices require the use of the interrupt endpoint of an
unrelated interface. This has so far been dealt with in usb-serial core,
but can now be moved to a driver calc_num_ports callback.

Note that we relax the endpoint requirements checked by core and instead
verify that we have an interrupt-in endpoint in calc_num_ports for all
devices so that the hack can first be applied.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:59:01 +02:00
Johan Hovold a794499b26 USB: serial: add calc_num_ports callback to generic driver
Add a calc_num_ports callback to the generic driver and verify that the
device has the required endpoints there instead of in core.

Note that the generic driver num_ports field was never used.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:54:39 +02:00
Johan Hovold 415d7b3a54 USB: serial: add probe callback to generic driver
Add a probe callback to the generic driver and print the
only-for-testing message there.

This is a first step in getting rid of the CONFIG_USB_SERIAL_GENERIC
ifdef from usb-serial core.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:54:39 +02:00
Johan Hovold 07814246dd USB: serial: allow subdrivers to modify port-endpoint mapping
Allow subdrivers to modify the port-endpoint mapping by passing the
endpoint descriptors to calc_num_ports.

The callback can now also be used to verify that the required endpoints
exists and abort probing otherwise.

This will allow us to get rid of a few hacks in subdrivers that are
already modifying the port-endpoint mapping (or aborting probe due to
missing endpoints), but only after the port structures have been setup.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:54:39 +02:00
Johan Hovold 92e6b2c675 USB: serial: add endpoint sanity check to core
Allow drivers to specify a minimum number of endpoints per type, which
USB serial core will verify after subdriver probe has returned (where
the current alternate setting may have been changed).

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:41 +01:00
Johan Hovold 8520ac0d70 USB: serial: replace runtime overflow check
Since commit 0a8fd13462 ("USB: fix problems with duplicate endpoint
addresses") USB core guarantees that there are no more than 15 endpoint
descriptors per type (and altsetting) so the corresponding overflow
checks can now be replaced with a compile-time check on the array sizes
(and indirectly the maximum number of ports).

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:41 +01:00
Johan Hovold 1546e6aecb USB: serial: refactor and clean up endpoint handling
Refactor and clean up endpoint handling.

This specifically moves the endpoint-descriptor arrays of the stack.

Note that an err_free_epds label is not yet added to avoid a compilation
warning when neither CONFIG_USB_SERIAL_PL2303 or
CONFIG_USB_SERIAL_GENERIC is selected.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:09 +01:00
Johan Hovold ef88f33fc1 USB: serial: clean up endpoint and port-counter types
Use unsigned-char type for the endpoint and port counters.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:13:37 +01:00
Johan Hovold c2fef4564c USB: serial: clean up probe error paths
Clean up the probe error paths by adding a couple of new error labels.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:13:36 +01:00
Johan Hovold 126d26f66d USB: serial: fix potential NULL-dereference at probe
Make sure we have at least one port before attempting to register a
console.

Currently, at least one driver binds to a "dummy" interface and requests
zero ports for it. Should such an interface also lack endpoints, we get
a NULL-deref during probe.

Fixes: e5b1e2062e ("USB: serial: make minor allocation dynamic")
Cc: stable <stable@vger.kernel.org>	# 3.11
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-10-21 16:47:17 +02:00