diff mbox series

[next] SFH: fix error return check for -ERESTARTSYS

Message ID 20201030143002.535531-1-colin.king@canonical.com
State Accepted
Commit 6e6eae04f5123b7b2f4265f7a702b5200fa5863b
Headers show
Series [next] SFH: fix error return check for -ERESTARTSYS | expand

Commit Message

Colin King Oct. 30, 2020, 2:30 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently the check for the error return code -ERESTARTSYS is dead code
and never executed because a previous check for ret < 0 is catching this
and returning -ETIMEDOUT instead.  Fix this by checking for -ERESTARTSYS
before the more generic negative error code.

Addresses-Coverity: ("Logically dead code")
Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Singh, Sandeep Nov. 9, 2020, 5:08 p.m. UTC | #1
On 10/30/2020 8:00 PM, Colin King wrote:
> [CAUTION: External Email]

>

> From: Colin Ian King <colin.king@canonical.com>

>

> Currently the check for the error return code -ERESTARTSYS is dead code

> and never executed because a previous check for ret < 0 is catching this

> and returning -ETIMEDOUT instead.  Fix this by checking for -ERESTARTSYS

> before the more generic negative error code.

>

> Addresses-Coverity: ("Logically dead code")

> Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")


Thank you for the patch ..looks good to me.

Reviewed-by: Sandeep Singh <sandeep.singh@amd.com>


> Signed-off-by: Colin Ian King <colin.king@canonical.com>

> ---

>   drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 6 +++---

>   1 file changed, 3 insertions(+), 3 deletions(-)

>

> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c

> index a471079a3bd0..4f989483aa03 100644

> --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c

> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c

> @@ -88,10 +88,10 @@ static int amdtp_wait_for_response(struct hid_device *hid)

>                  ret = wait_event_interruptible_timeout(hid_data->hid_wait,

>                                                         cli_data->request_done[i],

>                                                         msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));

> -       if (ret < 0)

> -               return -ETIMEDOUT;

> -       else if (ret == -ERESTARTSYS)

> +       if (ret == -ERESTARTSYS)

>                  return -ERESTARTSYS;

> +       else if (ret < 0)

> +               return -ETIMEDOUT;

>          else

>                  return 0;

>   }

> --

> 2.27.0

>
Jiri Kosina Nov. 12, 2020, 3:27 p.m. UTC | #2
On Fri, 30 Oct 2020, Colin King wrote:

> From: Colin Ian King <colin.king@canonical.com>

> 

> Currently the check for the error return code -ERESTARTSYS is dead code

> and never executed because a previous check for ret < 0 is catching this

> and returning -ETIMEDOUT instead.  Fix this by checking for -ERESTARTSYS

> before the more generic negative error code.

> 

> Addresses-Coverity: ("Logically dead code")

> Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")

> Signed-off-by: Colin Ian King <colin.king@canonical.com>


Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
diff mbox series

Patch

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
index a471079a3bd0..4f989483aa03 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
@@ -88,10 +88,10 @@  static int amdtp_wait_for_response(struct hid_device *hid)
 		ret = wait_event_interruptible_timeout(hid_data->hid_wait,
 						       cli_data->request_done[i],
 						       msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
-	if (ret < 0)
-		return -ETIMEDOUT;
-	else if (ret == -ERESTARTSYS)
+	if (ret == -ERESTARTSYS)
 		return -ERESTARTSYS;
+	else if (ret < 0)
+		return -ETIMEDOUT;
 	else
 		return 0;
 }