]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: vb2: use ssize_t for vb2_read/vb2_write
authorZile Xiong <xiongzile99@gmail.com>
Fri, 20 Mar 2026 06:54:45 +0000 (14:54 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 6 May 2026 07:05:56 +0000 (09:05 +0200)
commita562d6dc86bdfdd299e1b4734977a8d63e803583
tree6996bdee1feabcde16ece89ad193d986c4a4a2cf
parent084973ebd67b28f0945c5d45408f86c58b540110
media: vb2: use ssize_t for vb2_read/vb2_write

vb2_read() and vb2_write() return size_t, but propagate
negative errno values from __vb2_perform_fileio().

This relies on implicit signed/unsigned conversions in callers
(e.g. vb2_fop_read()) to recover error codes:

    __vb2_perform_fileio() -> -EINVAL
    vb2_read()             -> (size_t)-EINVAL
    vb2_fop_read()         -> -EINVAL

This relies on implicit conversions that are not obvious.

These helpers are exported (EXPORT_SYMBOL_GPL) and part of the
vb2 API, so changing their return type may affect existing users.

However, they conceptually follow read/write semantics, where
ssize_t is typically used to return either a byte count or a
negative error code.

Switch vb2_read() and vb2_write() to ssize_t, and update
__vb2_perform_fileio() accordingly.

Signed-off-by: Zile Xiong <xiongzile99@gmail.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: b25748fe6126 ("[media] v4l: videobuf2: add read() and write() emulator")
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/common/videobuf2/videobuf2-core.c
include/media/videobuf2-core.h