Commit Graph

8 Commits

Author SHA1 Message Date
Jose Ignacio Tornos Martinez 0e029f4ce7 USB: usbip: vudc: Convert to platform remove callback returning void
JIRA: https://issues.redhat.com/browse/RHEL-56984

commit b9a24821c7f7f8f8fbc9fc8539de96b60422d817
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Nov 3 18:14:29 2023 +0100

    USB: usbip: vudc: Convert to platform remove callback returning void
    
    The .remove() callback for a platform driver returns an int which makes
    many driver authors wrongly assume it's possible to do error handling by
    returning an error code. However the value returned is ignored (apart
    from emitting a warning) and this typically results in resource leaks.
    
    To improve here there is a quest to make the remove callback return
    void. In the first step of this quest all drivers are converted to
    .remove_new(), which already returns void. Eventually after all drivers
    are converted, .remove_new() will be renamed to .remove().
    
    Trivially convert this driver from always returning zero in the remove
    callback to the void returning variant.
    
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Link: https://lore.kernel.org/r/20231103171428.3636570-2-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-11-13 11:16:43 +01:00
Torez Smith 6c9afdcfb9 usb: usbip: eliminate anonymous module_init & module_exit
Bugzilla: http://bugzilla.redhat.com/2084667
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=46653455
Tested: HP ZBook 15 G5/80D5 Laptop

commit 393dcd1f2b75e50783c805814a96bf6c8e11fe03
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Wed Mar 16 12:20:08 2022 -0700

    usb: usbip: eliminate anonymous module_init & module_exit

    Eliminate anonymous module_init() and module_exit(), which can lead to
    confusion or ambiguity when reading System.map, crashes/oops/bugs,
    or an initcall_debug log.

    Give each of these init and exit functions unique driver-specific
    names to eliminate the anonymous names.

    Example 1: (System.map)
     ffffffff832fc78c t init
     ffffffff832fc79e t init
     ffffffff832fc8f8 t init

    Example 2: (initcall_debug log)
     calling  init+0x0/0x12 @ 1
     initcall init+0x0/0x12 returned 0 after 15 usecs
     calling  init+0x0/0x60 @ 1
     initcall init+0x0/0x60 returned 0 after 2 usecs
     calling  init+0x0/0x9a @ 1
     initcall init+0x0/0x9a returned 0 after 74 usecs

    Fixes: 80fd9cd52d ("usbip: vudc: Add VUDC main file")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Cc: Krzysztof Opasiak <k.opasiak@samsung.com>
    Cc: Igor Kotrasinski <i.kotrasinsk@samsung.com>
    Cc: Valentina Manea <valentina.manea.m@gmail.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Shuah Khan <skhan@linuxfoundation.org>
    Cc: linux-usb@vger.kernel.org
    Link: https://lore.kernel.org/r/20220316192010.19001-8-rdunlap@infradead.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-07-25 15:37:58 -04:00
Torez Smith e21a6caf12 usbip: vudc: Make use of the helper macro LIST_HEAD()
Bugzilla: http://bugzilla.redhat.com/2084667
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=46653455
Tested: HP ZBook 15 G5/80D5 Laptop

commit 4378e427f70577da86b41bb3380dbe237b6aa4d5
Author: Cai Huoqing <cai.huoqing@linux.dev>
Date:   Fri Feb 11 09:28:07 2022 +0800

    usbip: vudc: Make use of the helper macro LIST_HEAD()

    Replace "struct list_head head = LIST_HEAD_INIT(head)" with
    "LIST_HEAD(head)" to simplify the code.

    LIST_HEAD() helps to clean up the code "struct list_head vudc_devices =",
    only to care about the variable 'vudc_devices'.

    Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
    Link: https://lore.kernel.org/r/20220211012807.7415-1-cai.huoqing@linux.dev
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-07-25 15:37:36 -04:00
Greg Kroah-Hartman 91148dbad8 USB: usbip: convert platform driver to use dev_groups
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Valentina Manea <valentina.manea.m@gmail.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190805193636.25560-5-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-06 09:40:47 +02:00
Shuah Khan (Samsung OSG) e28fd56ad5 usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
In rmmod path, usbip_vudc does platform_device_put() twice once from
platform_device_unregister() and then from put_vudc_device().

The second put results in:

BUG kmalloc-2048 (Not tainted): Poison overwritten error or
BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
enabled.

[  169.042156] calling  init+0x0/0x1000 [usbip_vudc] @ 1697
[  169.042396] =============================================================================
[  169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs
[  169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten
[  169.044509] -----------------------------------------------------------------------------
...
[  169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693
[  169.057852] 	kobject_put+0x86/0x1b0
[  169.057853] 	0xffffffffc0c30a96
[  169.057855] 	__x64_sys_delete_module+0x157/0x240

Fix it to call platform_device_del() instead and let put_vudc_device() do
the platform_device_put().

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-18 19:44:39 +02:00
Greg Kroah-Hartman 7f2b019c8d USB: usbip: 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.

Cc: Valentina Manea <valentina.manea.m@gmail.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-07 15:45:01 +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
Igor Kotrasinski 80fd9cd52d usbip: vudc: Add VUDC main file
Add main vudc module file. This allows us to register suitable
platform device and driver (just like dummy_hcd does).

Currently number of vudc instances is determined using module
parameter but whole infrastructure is suitable to make vudc
creation dynamic (for example via configfs).

This commit is a result of cooperation between Samsung R&D Institute
Poland and Open Operating Systems Student Society at University
of Warsaw (O2S3@UW) consisting of:

    Igor Kotrasinski <ikotrasinsk@gmail.com>
    Karol Kosik <karo9@interia.eu>
    Ewelina Kosmider <3w3lfin@gmail.com>
    Dawid Lazarczyk <lazarczyk.dawid@gmail.com>
    Piotr Szulc <ps347277@students.mimuw.edu.pl>

Tutor and project owner:
    Krzysztof Opasiak <k.opasiak@samsung.com>

Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com>
Signed-off-by: Karol Kosik <karo9@interia.eu>
[Various bug fixes and commit message update]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26 15:19:50 -07:00