[Devel] [PATCH vz10] dm-ploop: return -ENOMEM (not ENOMEM) on mtfile allocation failure
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jun 4 12:19:30 MSK 2026
In ploop_add_delta() the kcalloc() failure path for deltas[level].mtfile
set a POSITIVE errno:
if (!deltas[level].mtfile) {
ret = ENOMEM;
goto out;
}
The only caller, ploop_add_deltas_stack(), treats the result as an error
with "if (ret < 0)", so a positive ENOMEM is not recognised as failure:
the stack-setup loop completes and returns 0 (success) while
deltas[level].mtfile stays NULL. Later IO paths then dereference
mtfile[pio->runner_id] (e.g. in the per-runner submit path) and NULL-deref.
Negate the value to -ENOMEM so the error is propagated.
Fixes: 16b86ada6062 ("dm-ploop: use filp per thread")
https://virtuozzo.atlassian.net/browse/VSTOR-132310
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 7746babf04a7..a7849de8aaa6 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -507,7 +507,7 @@ int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_r
deltas[level].mtfile = kcalloc(ploop->nkt_runners, sizeof(*file),
GFP_KERNEL);
if (!deltas[level].mtfile) {
- ret = ENOMEM;
+ ret = -ENOMEM;
goto out;
}
for (i = 0; i < ploop->nkt_runners; i++) {
--
2.47.1
More information about the Devel
mailing list