Skip to content

selftests/ublk: add NULL check after calloc() - #162

Open
blktests-ci-block-trial[bot] wants to merge 2 commits into
master_basefrom
series/777=>master
Open

blktests-ci-block-trial[bot] wants to merge 2 commits into
master_basefrom
series/777=>master

Conversation

@blktests-ci-block-trial

Copy link
Copy Markdown

Pull request for series with
subject: selftests/ublk: add NULL check after calloc()
version: 1
url: http://redsun45:8000/project/linux-block/list/?series=777

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: 89a3129
series: http://redsun45:8000/project/linux-block/list/?series=777
version: 1

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: 89a3129
series: http://redsun45:8000/project/linux-block/list/?series=777
version: 1

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: 940de59
series: http://redsun45:8000/project/linux-block/list/?series=777
version: 1

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: 841e384
series: http://redsun45:8000/project/linux-block/list/?series=777
version: 1

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: a500db7
series: http://redsun45:8000/project/linux-block/list/?series=777
version: 1

Three calloc() calls in the ublk selftests lack NULL return checks,
leading to potential NULL pointer dereferences on allocation failure:

1. kublk.c ublk_ctrl_init(): the allocated `dev` is dereferenced
   immediately via `info = &dev->dev_info` without checking for NULL.

2. batch.c alloc_batch_commit_buf(): the allocated `t->commit` is
   dereferenced in the following for-loop without checking for NULL.

3. batch.c alloc_batch_fetch_buf(): the allocated `t->fetch` is
   dereferenced in the following for-loop without checking for NULL.

Add NULL checks after each calloc(), returning NULL or -ENOMEM consistent
with existing error handling in the same functions.

Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
@blktests-ci-block-trial
blktests-ci-block-trial Bot force-pushed the master_base branch 7 times, most recently from 73fe3ff to 15f6e70 Compare September 16, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant