mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Karol Przybylski <karprzy7@gmail.com>, mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org
Subject: Re: [PATCH] media: cec: extron-da-hd-4k-plus: add return check for wait_for_completion*()
Date: Mon, 11 Nov 2024 09:04:11 +0100	[thread overview]
Message-ID: <4168e5ef-c2b6-435d-830f-c9d6faad6bfe@xs4all.nl> (raw)
In-Reply-To: <20241110125814.1899076-1-karprzy7@gmail.com>

On 10/11/2024 13:58, Karol Przybylski wrote:
> 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.

There is no need to check the return code in this specific case.

If the wait was successful, then port->edid_blocks will be set, so
effectively that 'if' is the result check of the wait_for_completion
call.

Regards,

	Hans

> 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;


      parent reply	other threads:[~2024-11-11  8:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-10 12:58 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 message]

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=4168e5ef-c2b6-435d-830f-c9d6faad6bfe@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=karprzy7@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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®