* [PATCH] staging: vme_user: fix probe error path resource handling
@ 2026-10-31 13:34 linfordWu
2026-10-31 13:50 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: linfordWu @ 2026-10-31 13:34 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, linfordWu
The probe error paths free the current master or slave resource before
jumping to cleanup loops that free it again. They also pass NULL
resources to the VME release helpers when window allocation fails, and
pass a NULL buffer to vme_free_consistent() when buffer allocation
fails.
Let the common cleanup paths own all resource releases and guard the
resource and buffer pointers so each failure path only releases objects
that were allocated successfully.
Signed-off-by: linfordWu <linfordwu@163.com>
---
drivers/staging/vme_user/vme_user.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/vme_user/vme_user.c b/drivers/staging/vme_user/vme_user.c
index a472a38ef61..980798ae622 100644
--- a/drivers/staging/vme_user/vme_user.c
+++ b/drivers/staging/vme_user/vme_user.c
@@ -616,7 +616,6 @@ static int vme_user_probe(struct vme_dev *vdev)
dev_warn(&vdev->dev,
"Unable to allocate memory for buffer\n");
image[i].pci_buf = 0;
- vme_slave_free(image[i].resource);
err = -ENOMEM;
goto err_slave;
}
@@ -641,7 +640,6 @@ static int vme_user_probe(struct vme_dev *vdev)
image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL);
if (!image[i].kern_buf) {
err = -ENOMEM;
- vme_master_free(image[i].resource);
goto err_master;
}
}
@@ -698,7 +696,8 @@ static int vme_user_probe(struct vme_dev *vdev)
while (i > MASTER_MINOR) {
i--;
kfree(image[i].kern_buf);
- vme_master_free(image[i].resource);
+ if (image[i].resource)
+ vme_master_free(image[i].resource);
}
/*
@@ -708,9 +707,11 @@ static int vme_user_probe(struct vme_dev *vdev)
err_slave:
while (i > SLAVE_MINOR) {
i--;
- vme_free_consistent(image[i].resource, image[i].size_buf,
- image[i].kern_buf, image[i].pci_buf);
- vme_slave_free(image[i].resource);
+ if (image[i].kern_buf)
+ vme_free_consistent(image[i].resource, image[i].size_buf,
+ image[i].kern_buf, image[i].pci_buf);
+ if (image[i].resource)
+ vme_slave_free(image[i].resource);
}
err_class:
cdev_del(vme_user_cdev);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] staging: vme_user: fix probe error path resource handling
2026-10-31 13:34 [PATCH] staging: vme_user: fix probe error path resource handling linfordWu
@ 2026-10-31 13:50 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-10-31 13:50 UTC (permalink / raw)
To: linfordWu; +Cc: Greg Kroah-Hartman, linux-staging, linux-kernel
On Sat, Oct 31, 2026 at 09:34:33PM +0800, linfordWu wrote:
> The probe error paths free the current master or slave resource before
> jumping to cleanup loops that free it again. They also pass NULL
> resources to the VME release helpers when window allocation fails, and
> pass a NULL buffer to vme_free_consistent() when buffer allocation
> fails.
>
> Let the common cleanup paths own all resource releases and guard the
> resource and buffer pointers so each failure path only releases objects
> that were allocated successfully.
>
> Signed-off-by: linfordWu <linfordwu@163.com>
This driver has been removed from the latest tree.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-31 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 13:34 [PATCH] staging: vme_user: fix probe error path resource handling linfordWu
2026-10-31 13:50 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®