devfs: Fix incorrect error check for cdev->ops->lseek()
Cdev->ops->lseek() will either return a negative error code on failure
or requested position on success. In order to properly check for
errors we need to test if the return value is negative, not just that
it's not -1.

Returning ret - cdev->offset, doesn't appear to be correct either,
even if ret is -1, since on failure this will lead us to return (-1 -
cdev->offset). Simplify that part by just returning 'pos', which is
what we'd end up returning on success in original code as well.

Third, make sure to return -ENOSYS, when no .lseek() callback is
provided.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 332304d commit 6811cc0dbc04c71cdc1ff12efe0edc8660200563
@Andrey Smirnov Andrey Smirnov authored on 29 Jan 2019
Sascha Hauer committed on 29 Jan 2019
Showing 1 changed file
View
fs/devfs.c