linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM
@ 2020-06-03 15:21 Colin King
  2020-06-03 17:31 ` Dan Carpenter
  2020-08-06 22:34 ` Dmitry Torokhov
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2020-06-03 15:21 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: kernel-janitors, linux-kernel

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

Currently the assignment of -ENOMEM to error is redudant because error
is not being read and -ENOMEM is being hard coded as an error return.
Fix this by returning the error code in variable 'error'; this also
allows the error code from a failed call to input_register_device to
be preserved and returned to the caller rather than just returning
a possibly inappropriate -ENOMEM.

Kudos to Dan Carpenter for the suggestion of an improved fix.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>

---

V2: change subject line and return the error code rather than
    removing the ENOMEM assignment to error. Thanks to Dan Carpenter
    for explaining a better fix.

---
 drivers/input/misc/ims-pcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index d8dbfc030d0f..08b9b5cdb943 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -335,7 +335,7 @@ static int ims_pcu_setup_gamepad(struct ims_pcu *pcu)
 err_free_mem:
 	input_free_device(input);
 	kfree(gamepad);
-	return -ENOMEM;
+	return error;
 }
 
 static void ims_pcu_destroy_gamepad(struct ims_pcu *pcu)
-- 
2.25.1


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

* Re: [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM
  2020-06-03 15:21 [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM Colin King
@ 2020-06-03 17:31 ` Dan Carpenter
  2020-08-06 22:34 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-06-03 17:31 UTC (permalink / raw)
  To: Colin King; +Cc: Dmitry Torokhov, linux-input, kernel-janitors, linux-kernel

On Wed, Jun 03, 2020 at 04:21:51PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the assignment of -ENOMEM to error is redudant because error
> is not being read and -ENOMEM is being hard coded as an error return.
> Fix this by returning the error code in variable 'error'; this also
> allows the error code from a failed call to input_register_device to
> be preserved and returned to the caller rather than just returning
> a possibly inappropriate -ENOMEM.
> 
> Kudos to Dan Carpenter for the suggestion of an improved fix.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


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

* Re: [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM
  2020-06-03 15:21 [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM Colin King
  2020-06-03 17:31 ` Dan Carpenter
@ 2020-08-06 22:34 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2020-08-06 22:34 UTC (permalink / raw)
  To: Colin King; +Cc: linux-input, kernel-janitors, linux-kernel

On Wed, Jun 03, 2020 at 04:21:51PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the assignment of -ENOMEM to error is redudant because error
> is not being read and -ENOMEM is being hard coded as an error return.
> Fix this by returning the error code in variable 'error'; this also
> allows the error code from a failed call to input_register_device to
> be preserved and returned to the caller rather than just returning
> a possibly inappropriate -ENOMEM.
> 
> Kudos to Dan Carpenter for the suggestion of an improved fix.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 

Applied, thank you.

-- 
Dmitry

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

end of thread, other threads:[~2020-08-06 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 15:21 [PATCH][V2] input: ims-pcu: return error code rather than -ENOMEM Colin King
2020-06-03 17:31 ` Dan Carpenter
2020-08-06 22:34 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).