]> 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>
Thu, 5 Dec 2024 09:59:37 +0000 (10:59 +0100)
commitd08bdcb6ad739d7276cabbb491a6ee4feccfaf86
tree0e46595edfe65b5cefd0944413bc4479b141483c
parentcf27feb9fe269afd95bbc71fa8da78623114d49f
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