[Devel] [PATCH RHEL10 COMMIT] dm-ploop: return -ENOMEM (not ENOMEM) on mtfile allocation failure

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 15 13:58:09 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.el10
------>
commit 593c8c828fcbf7ce6c7e81cb919989f3e6e22830
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Wed Jun 3 23:54:58 2026 +0200

    dm-ploop: return -ENOMEM (not ENOMEM) on mtfile allocation failure
    
    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: 762b90ec3324 ("dm-ploop: use filp per thread")
    https://virtuozzo.atlassian.net/browse/VSTOR-132310
    Feature: dm-ploop: ploop target driver
    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++) {


More information about the Devel mailing list