mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: cec: extron-da-hd-4k-plus: add return check for wait_for_completion*()
@ 2024-11-10 12:58 Karol Przybylski
  2024-11-10 15:52 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karol Przybylski @ 2024-11-10 12:58 UTC (permalink / raw)
  To: hverkuil, mchehab; +Cc: Karol Przybylski, linux-media, linux-kernel, skhan

According to scheduler/completion.rst, return status of wait_for_completion*()
function variants should be checked or be accompanied by explanation.

I examined code in extron-da-hd-4k-plus.c and it does look like the return value
should be checked, but perhaps there is a reason for ignoring it.
I drafted a patch for this, but I'm not entirely sure how to approach error handling in this case.

Discovered in coverity, CID1599679

Signed-off-by: Karol Przybylski <karprzy7@gmail.com>
---
 .../cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
index cfbfc4c1b2e6..83a790117411 100644
--- a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
+++ b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
@@ -559,9 +559,12 @@ static void extron_read_edid(struct extron_port *port)
 
 	extron->edid_reading = true;
 
-	if (!extron_send_and_wait(extron, port, cmd, reply))
-		wait_for_completion_killable_timeout(&extron->edid_completion,
+	if (!extron_send_and_wait(extron, port, cmd, reply)) {
+		ret = wait_for_completion_killable_timeout(&extron->edid_completion,
 						     msecs_to_jiffies(1000));
+		if (ret < 0)
+			goto unlock;
+	}
 	if (port->edid_blocks) {
 		extron_parse_edid(port);
 		port->read_edid = true;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-11  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-10 12:58 [PATCH] media: cec: extron-da-hd-4k-plus: add return check for wait_for_completion*() Karol Przybylski
2024-11-10 15:52 ` kernel test robot
2024-11-11  3:48 ` kernel test robot
2024-11-11  8:04 ` Hans Verkuil

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®