]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()
authorJeongjun Park <aha310510@gmail.com>
Thu, 19 Sep 2024 10:34:03 +0000 (19:34 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 13:16:04 +0000 (15:16 +0200)
commit44feafbaa66ec86232b123bb8437a6a262442025
treef035c5f78ceaa58fdbeecc5c8a8a8724e5cfa7f6
parent67c6150c0c5faeaaf5cf5c1b1cc6501d431d58d1
usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()

iowarrior_read() uses the iowarrior dev structure, but does not use any
lock on the structure. This can cause various bugs including data-races,
so it is more appropriate to use a mutex lock to safely protect the
iowarrior dev structure. When using a mutex lock, you should split the
branch to prevent blocking when the O_NONBLOCK flag is set.

In addition, it is unnecessary to check for NULL on the iowarrior dev
structure obtained by reading file->private_data. Therefore, it is
better to remove the check.

Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
Link: https://lore.kernel.org/r/20240919103403.3986-1-aha310510@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/iowarrior.c