]> 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>
Sat, 14 Dec 2024 18:51:10 +0000 (19:51 +0100)
commitdc26c8db0837661a9c8bd54b3d51e1674df4249d
tree554ffbcc21038378895ff2de864fc4596101cca6
parentbc2dbad38537f88b94210bccc490b9621d8ebc38
usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()

[ Upstream commit 44feafbaa66ec86232b123bb8437a6a262442025 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/misc/iowarrior.c