From: Riccardo Oliva <oliva.scorza@gmail.com>
To: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, oliva.scorza@gmail.com
Subject: [PATCH] staging: vme_user: avoid iterator variable access outside list loop
Date: Sun, 11 Oct 2026 22:40:20 -0500 [thread overview]
Message-ID: <20261012034020.100737-1-oliva.scorza@gmail.com> (raw)
In vme_slave_request(), vme_master_request(), vme_dma_request(), and
vme_lm_request(), the list iterators (slave_image, master_image,
dma_ctrlr, and lm) are accessed in the err_alloc error paths after
exiting the list_for_each_entry() loops.
While the iterator variable retains its pointer value upon hitting a
break, accessing list iterators outside the loop body violates modern
kernel coding standards.
Fix this by referencing the dedicated allocated resource pointers
(allocated_image, allocated_ctrlr, allocated_lm) in the error cleanup
blocks instead.
Signed-off-by: Riccardo Oliva <oliva.scorza@gmail.com>
---
Hi! This is my first patch to the kernel. I am learning the submission
workflow. Any feedback is very much appreciated. Thanks!
drivers/staging/vme_user/vme.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/vme_user/vme.c b/drivers/staging/vme_user/vme.c
index b5c66b66c..d38c792eb 100644
--- a/drivers/staging/vme_user/vme.c
+++ b/drivers/staging/vme_user/vme.c
@@ -298,9 +298,9 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
err_alloc:
/* Unlock image */
- mutex_lock(&slave_image->mtx);
- slave_image->locked = 0;
- mutex_unlock(&slave_image->mtx);
+ mutex_lock(&allocated_image->mtx);
+ allocated_image->locked = 0;
+ mutex_unlock(&allocated_image->mtx);
err_image:
err_bus:
return NULL;
@@ -495,9 +495,9 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
err_alloc:
/* Unlock image */
- spin_lock(&master_image->lock);
- master_image->locked = 0;
- spin_unlock(&master_image->lock);
+ spin_lock(&allocated_image->lock);
+ allocated_image->locked = 0;
+ spin_unlock(&allocated_image->lock);
err_image:
err_bus:
return NULL;
@@ -865,9 +865,9 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
err_alloc:
/* Unlock image */
- mutex_lock(&dma_ctrlr->mtx);
- dma_ctrlr->locked = 0;
- mutex_unlock(&dma_ctrlr->mtx);
+ mutex_lock(&allocated_ctrlr->mtx);
+ allocated_ctrlr->locked = 0;
+ mutex_unlock(&allocated_ctrlr->mtx);
err_ctrlr:
err_bus:
return NULL;
@@ -1469,9 +1469,9 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
err_alloc:
/* Unlock image */
- mutex_lock(&lm->mtx);
- lm->locked = 0;
- mutex_unlock(&lm->mtx);
+ mutex_lock(&allocated_lm->mtx);
+ allocated_lm->locked = 0;
+ mutex_unlock(&allocated_lm->mtx);
err_lm:
err_bus:
return NULL;
--
2.43.0
next reply other threads:[~2026-10-12 3:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 3:40 Riccardo Oliva [this message]
2026-10-13 13:40 ` Greg KH
2026-10-13 17:30 ` Riccardo Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261012034020.100737-1-oliva.scorza@gmail.com \
--to=oliva.scorza@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®