media: uvcvideo: avoid variable shadowing in uvc_ctrl_cleanup_fh
Subsystems (2)
PATCH v2 1/1 media: uvcvideo: avoid variable shadowing in uvc_ctrl_cleanup_fh
This avoids a variable loop shadowing occurring between the local loop iterating through the uvc_entity's controls and the global one going through the pending async controls of the file handle
--- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +2 -2
@@ -3260,7 +3260,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)void uvc_ctrl_cleanup_fh (struct uvc_fh *handle) {struct uvc_entity *entity; -int i; +unsigned int i;guard (mutex)(&handle->chain->ctrl_mutex);
@@ -3268,7 +3268,7 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle)return ;list_for_each_entry (entity, &handle->chain->dev->entities, list) { -for (unsigned int i =0 ; i < entity->ncontrols; ++i) { +for (i =0 ; i < entity->ncontrols; ++i) {if (entity->controls[i].handle != handle)continue ;uvc_ctrl_set_handle (handle, &entity->controls[i],NULL );
Signature · 1 line
2.49.0
Quoted 7 lines · Desnes Nunes
This avoids a variable loop shadowing occurring between the local loop iterating through the uvc_entity's controls and the global one going through the pending async controls of the file handle
Fixes 10acb9101355 ("media: uvcvideo: Increase/decrease the PM counter per IOCTL")
Quoted 31 lines
Signed-off-by Desnes Nunes <[email protected]>--- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/usb/uvc/uvc_ctrl.c +2
-3@@ -3260,7 +3260,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)void uvc_ctrl_cleanup_fh (struct uvc_fh *handle) {struct uvc_entity *entity; -int i; +unsigned int i;guard (mutex)(&handle->chain->ctrl_mutex);@@ -3268,7 +3268,7 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle)return ;list_for_each_entry (entity, &handle->chain->dev->entities, list) { -for (unsigned int i =0 ; i < entity->ncontrols; ++i) { +for (i =0 ; i < entity->ncontrols; ++i) {if (entity->controls[i].handle != handle)continue ;uvc_ctrl_set_handle (handle, &entity->controls[i],NULL ); --2.49.0
Signature · 1 line
Ricardo Ribalda
Hans de Goede
maintainerHi,
Quoted 7 lines · Desnes Nunes
This avoids a variable loop shadowing occurring between the local loop iterating through the uvc_entity's controls and the global one going through the pending async controls of the file handle
Fixes 10acb9101355 ("media: uvcvideo: Increase/decrease the PM counter per IOCTL")Signed-off-by Desnes Nunes <[email protected]>
Thank you for the new version.
I've pushed this to uvc/for-next now:
https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/for-next/
Note I had to manually apply the patch because of it conflicting with:
So if you want this backported to stable you will need to send the original version to stable your self.
I plan to send a pull-request with the changes from for-next this Thursday.
Regards,
Hans
Quoted 26 lines
--- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/usb/uvc/uvc_ctrl.c +2
-2@@ -3260,7 +3260,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)void uvc_ctrl_cleanup_fh (struct uvc_fh *handle) {struct uvc_entity *entity; -int i; +unsigned int i;guard (mutex)(&handle->chain->ctrl_mutex);@@ -3268,7 +3268,7 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle)return ;list_for_each_entry (entity, &handle->chain->dev->entities, list) { -for (unsigned int i =0 ; i < entity->ncontrols; ++i) { +for (i =0 ; i < entity->ncontrols; ++i) {if (entity->controls[i].handle != handle)continue ;uvc_ctrl_set_handle (handle, &entity->controls[i],NULL );
Laurent Pinchart
maintainerHi Hans,
Quoted 9 lines · Hans de Goede
Quoted 7 lines · Desnes Nunes
This avoids a variable loop shadowing occurring between the local loop iterating through the uvc_entity's controls and the global one going through the pending async controls of the file handle
Fixes 10acb9101355 ("media: uvcvideo: Increase/decrease the PM counter per IOCTL")Signed-off-by Desnes Nunes <[email protected]>
Quoted 5 lines
Thank you for the new version.
I've pushed this to uvc/for-next now:
https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/for-next/
As mentioned during the review (see [email protected]), I still prefer local loop variables. Can we use that please ?
Quoted 36 lines
Note I had to manually apply the patch because of it conflicting with:
So if you want this backported to stable you will need to send the original version to stable your self.
I plan to send a pull-request with the changes from for-next this Thursday.
Quoted 26 lines
--- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/usb/uvc/uvc_ctrl.c +2
-2@@ -3260,7 +3260,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)void uvc_ctrl_cleanup_fh (struct uvc_fh *handle) {struct uvc_entity *entity; -int i; +unsigned int i;guard (mutex)(&handle->chain->ctrl_mutex);@@ -3268,7 +3268,7 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle)return ;list_for_each_entry (entity, &handle->chain->dev->entities, list) { -for (unsigned int i =0 ; i < entity->ncontrols; ++i) { +for (i =0 ; i < entity->ncontrols; ++i) {if (entity->controls[i].handle != handle)continue ;uvc_ctrl_set_handle (handle, &entity->controls[i],NULL );
Signature · 3 lines
Regards, Laurent Pinchart
Hans de Goede
maintainerHi,
Quoted 14 lines · Laurent Pinchart
Hi Hans,
Quoted 11 lines · Hans de Goede
Quoted 7 lines · Desnes Nunes
This avoids a variable loop shadowing occurring between the local loop iterating through the uvc_entity's controls and the global one going through the pending async controls of the file handle
Fixes 10acb9101355 ("media: uvcvideo: Increase/decrease the PM counter per IOCTL")Signed-off-by Desnes Nunes <[email protected]>Thank you for the new version.
Quoted 7 lines
Quoted 3 lines
I've pushed this to uvc/for-next now:
https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/for-next/
As mentioned during the review (see [email protected]), I still prefer local loop variables. Can we use that please ?
Ok, I'll drop this from for-next.
Desnes, can you prepare a v3 moving the toplevel declation inside the other loop please ?
Regards,
Hans
Quoted 37 lines
Quoted 36 lines
Note I had to manually apply the patch because of it conflicting with:
So if you want this backported to stable you will need to send the original version to stable your self.
I plan to send a pull-request with the changes from for-next this Thursday.
Quoted 26 lines
--- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/usb/uvc/uvc_ctrl.c +2
-2@@ -3260,7 +3260,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev)void uvc_ctrl_cleanup_fh (struct uvc_fh *handle) {struct uvc_entity *entity; -int i; +unsigned int i;guard (mutex)(&handle->chain->ctrl_mutex);@@ -3268,7 +3268,7 @@ void uvc_ctrl_cleanup_fh(struct uvc_fh *handle)return ;list_for_each_entry (entity, &handle->chain->dev->entities, list) { -for (unsigned int i =0 ; i < entity->ncontrols; ++i) { +for (i =0 ; i < entity->ncontrols; ++i) {if (entity->controls[i].handle != handle)continue ;uvc_ctrl_set_handle (handle, &entity->controls[i],NULL );
Hello Hans,
On Mon, Jul 7, 2025 at 10:01 AM Hans de Goede <[email protected]> wrote:
...
Quoted 8 lines
Quoted 3 lines
As mentioned during the review (see [email protected]), I still prefer local loop variables. Can we use that please ?
Ok, I'll drop this from for-next.
Desnes, can you prepare a v3 moving the toplevel declation inside the other loop please ?
Sure, I will send a v3 with the requested changes today.
Best Regards,
Signature · 1 line
Desnes Nunes