V4L2 async fixes
Subsystems (2)
Sakari Ailus
maintainercover V4L2 async fixes
Hi folks,
This set fixes a few issues in V4L2 async regarding error paths and uneven calls to teardown functions. I ended up taking a fresh look at the code after Alexander posted his patch (message id [email protected]).
Sakari Ailus (2):
media: v4l: async: Don't set notifier's V4L2 device if registering
fails
media: v4l: async: Properly check for a notifier initialised or
registered
drivers/media/v4l2-core/v4l2-async.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.2
Sakari Ailus
maintainerPATCH 1/2 media: v4l: async: Don't set notifier's V4L2 device if registering fails
The V4L2 device used to be set when the notifier was registered but this has been moved to the notifier initialisation. Don't touch the V4L2 device if registration fails.
--- drivers/media/v4l2-core/v4l2-async.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +1 -7
@@ -620,16 +620,10 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier)int v4l2_async_nf_register (struct v4l2_async_notifier *notifier) { -int ret; -if (WARN_ON (!notifier->v4l2_dev == !notifier->sd))return -EINVAL ; - ret =__v4l2_async_nf_register (notifier); -if (ret) - notifier->v4l2_dev =NULL ; - -return ret; +return __v4l2_async_nf_register (notifier); }EXPORT_SYMBOL (v4l2_async_nf_register);
Signature · 1 line
2.39.2
Sakari Ailus
maintainerPATCH 2/2 media: v4l: async: Properly check for a notifier initialised or registered
In reply to Sakari AilusProperly check that a notifier was never initialised or register. This can now be done by looking at the entry in the notifier list, not the V4L2 device or sub-device that are set in the initialiser now.
--- drivers/media/v4l2-core/v4l2-async.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +4 -2
@@ -630,12 +630,14 @@ EXPORT_SYMBOL(v4l2_async_nf_register);static void __v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier) { -if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) +/* Return here if the notifier is never initialised or registered. */ +if (!notifier->notifier_entry.next || +list_empty (¬ifier->notifier_entry))return ;v4l2_async_nf_unbind_all_subdevs (notifier); -list_del (¬ifier->notifier_entry); +list_del_init (¬ifier->notifier_entry); }void v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier)
Signature · 1 line
2.39.2
Re: [PATCH 2/2] media: v4l: async: Properly check for a notifier initialised or registered
Hi Sakari,
I suppose on of your intentions of this series is to replace my patch, no?
Am Montag, 11. März 2024, 13:17:41 CET schrieb Sakari Ailus:
Quoted 15 lines
Properly check that a notifier was never initialised or register. This can now be done by looking at the entry in the notifier list, not the V4L2 device or sub-device that are set in the initialiser now.
Fixes b8ec754ae4c5 ("media: v4l: async: Set v4l2_device and subdev in async notifier init")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/media/v4l2-core/v4l2-async.c +0
-0
drivers/media/v4l2-core/v4l2-async.c EXPORT_SYMBOL(v4l2_async_nf_register); · line 634
Quoted 6 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -630,12 +630,14 @@ EXPORT_SYMBOL(v4l2_async_nf_register);static void __v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier) { -if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) +/* Return here if the notifier is never initialised or registered. */ + if (!notifier->notifier_entry.next ||
I don't like the idea checking the next pointer of a list. Despite that it's not even necessary.
Best regards,
Alexander
Quoted 11 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1+ list_empty(¬ifier->notifier_entry))return ;v4l2_async_nf_unbind_all_subdevs (notifier); -list_del (¬ifier->notifier_entry); +list_del_init (¬ifier->notifier_entry); }void v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier)
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Sakari Ailus
maintainerRe: [PATCH 2/2] media: v4l: async: Properly check for a notifier initialised or registered
Hi Alexander,
Quoted 3 lines · Alexander Stein
Hi Sakari,
I suppose on of your intentions of this series is to replace my patch, no?
No, these are somewhat unrelated issues.
Quoted 12 lines
Am Montag, 11. März 2024, 13:17:41 CET schrieb Sakari Ailus:
Quoted 10 lines
Properly check that a notifier was never initialised or register. This can now be done by looking at the entry in the notifier list, not the V4L2 device or sub-device that are set in the initialiser now.
Fixes b8ec754ae4c5 ("media: v4l: async: Set v4l2_device and subdev in async notifier init")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 14 lines
drivers/media/v4l2-core/v4l2-async.c EXPORT_SYMBOL(v4l2_async_nf_register); · line 634
Quoted 11 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -630,12 +630,14 @@ EXPORT_SYMBOL(v4l2_async_nf_register);static void __v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier) { -if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) +/* Return here if the notifier is never initialised or registered. */ + if (!notifier->notifier_entry.next ||I don't like the idea checking the next pointer of a list. Despite that it's not even necessary.
Actually I think we can drop the above change. But the list_del_init() below is still necessary.
Quoted 17 lines
Best regards,
AlexanderQuoted 11 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1+ list_empty(¬ifier->notifier_entry))return ;v4l2_async_nf_unbind_all_subdevs (notifier); -list_del (¬ifier->notifier_entry); +list_del_init (¬ifier->notifier_entry); }void v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier)
Signature · 3 lines
Regards, Sakari Ailus
Re: [PATCH 2/2] media: v4l: async: Properly check for a notifier initialised or registered
Hi Sakari,
Am Mittwoch, 20. März 2024, 08:07:51 CET schrieb Sakari Ailus:
Quoted 8 lines
Hi Alexander,
Quoted 3 lines · Alexander Stein
Hi Sakari,
I suppose on of your intentions of this series is to replace my patch, no?
No, these are somewhat unrelated issues.
Okay, thanks for confirmation.
Quoted 27 lines
Quoted 12 lines
Am Montag, 11. März 2024, 13:17:41 CET schrieb Sakari Ailus:
Quoted 10 lines
Properly check that a notifier was never initialised or register. This can now be done by looking at the entry in the notifier list, not the V4L2 device or sub-device that are set in the initialiser now.
Fixes b8ec754ae4c5 ("media: v4l: async: Set v4l2_device and subdev in async notifier init")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Quoted 14 lines
drivers/media/v4l2-core/v4l2-async.c EXPORT_SYMBOL(v4l2_async_nf_register); · line 634
Quoted 11 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -630,12 +630,14 @@ EXPORT_SYMBOL(v4l2_async_nf_register);static void __v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier) { -if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) +/* Return here if the notifier is never initialised or registered. */ + if (!notifier->notifier_entry.next ||I don't like the idea checking the next pointer of a list. Despite that it's not even necessary.
Quoted 2 lines
Actually I think we can drop the above change. But the
list_del_init()below is still necessary.
I agree about the list_del_init() change.
Best regards,
Alexander
Quoted 19 lines
Quoted 17 lines
Best regards,
AlexanderQuoted 11 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1+ list_empty(¬ifier->notifier_entry))return ;v4l2_async_nf_unbind_all_subdevs (notifier); -list_del (¬ifier->notifier_entry); +list_del_init (¬ifier->notifier_entry); }void v4l2_async_nf_unregister (struct v4l2_async_notifier *notifier)
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/