Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iolog, dataplacement: fix coverity scan defect #1767

Merged
merged 2 commits into from
May 31, 2024

Conversation

parkvibes
Copy link
Contributor

@parkvibes parkvibes commented May 30, 2024

iolog: fix Error handling issues (NEGATIVE_RETURNS)

CID 494151: Error handling issues (NEGATIVE_RETURNS) @ io_u.c:1877 in get_io_u()
This patch removes negative returns from dp_init() to ensure
its value can be properly consumed by td_verror()

Signed-off-by: Hyunwoo Park dshw.park@samsung.com

iolog: fix Null pointer dereferences (FORWARD_NULL)

CID 494150: Null pointer dereferences (FORWARD_NULL) @ iolog.c:148 in ipo_special()
This patch removes the possibility of null pointer dereferencing(io_u->file)
throughout the call stack of get_io_u() → read_iolog_get() → dp_fill_dspec_data()

Signed-off-by: Hyunwoo Park dshw.park@samsung.com

@vincentkfu
Copy link
Collaborator

Please change the first lines of the commit messages to describe the actual issue instead of just writing that the issue was identified by coverity.

@vincentkfu
Copy link
Collaborator

For the negative errno issue I would much rather see code that does something like what zbd.c:zbd_init_zone_info() does:

        ret = zbd_create_zone_info(td, file);
        if (ret < 0)
                td_verror(td, -ret, "zbd_create_zone_info() failed");

Just negate the value sent to td_verror(). This involves fewer code changes than your patch.

I do not know the full history of returning negative errno values but this is a common pattern: https://stackoverflow.com/questions/36845866/history-of-using-negative-errno-values-in-gnu

@parkvibes
Copy link
Contributor Author

parkvibes commented May 31, 2024

As dp_init() can return a positive value, I made dp_init_ret an absolute value using abs(dp_init_ret) instead of -dp_init_ret

CID 494150: Null pointer dereferences (FORWARD_NULL) @ iolog.c:148 in ipo_special()
This patch removes the possibility of null pointer dereferencing(io_u->file)
throughout the call stack of get_io_u() → read_iolog_get() → dp_fill_dspec_data()

Signed-off-by: Hyunwoo Park <dshw.park@samsung.com>
CID 494151: Error handling issues (NEGATIVE_RETURNS) @ io_u.c:1877 in get_io_u()
This patch removes negative returns from dp_init() to ensure
its value can be properly consumed by td_verror()

Signed-off-by: Hyunwoo Park <dshw.park@samsung.com>
@axboe axboe merged commit 93dc854 into axboe:master May 31, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants