* [PATCH] Input: ims-pcu - fix uninitialized use of 'error' in ims_pcu_buffers_alloc()
@ 2014-05-18 21:41 Christian Engelmayer
2014-05-18 23:00 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Christian Engelmayer @ 2014-05-18 21:41 UTC (permalink / raw)
To: linux-input
Cc: dmitry.torokhov, andrew.smirnov, linux-kernel,
Christian Engelmayer
In case allocation via usb_alloc_coherent() fails in ims_pcu_buffers_alloc(),
the function jumps to the exit path without initializing local variable
'error' that is used as return value. Detected by Coverity - CID 1016531.
Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
---
This is an allocation function and all currently coded error scenarios
result in -ENOMEM. Thus it would be possible to eliminate 'error' at all and
always return -ENOMEM in the error path.
Compile tested. Applies against branch next in tree
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
---
drivers/input/misc/ims-pcu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 5a73639..719410f 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1566,6 +1566,7 @@ static int ims_pcu_buffers_alloc(struct ims_pcu *pcu)
if (!pcu->urb_ctrl_buf) {
dev_err(pcu->dev,
"Failed to allocate memory for read buffer\n");
+ error = -ENOMEM;
goto err_free_urb_out_buf;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: ims-pcu - fix uninitialized use of 'error' in ims_pcu_buffers_alloc()
2014-05-18 21:41 [PATCH] Input: ims-pcu - fix uninitialized use of 'error' in ims_pcu_buffers_alloc() Christian Engelmayer
@ 2014-05-18 23:00 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-05-18 23:00 UTC (permalink / raw)
To: Christian Engelmayer; +Cc: linux-input, andrew.smirnov, linux-kernel
On Sun, May 18, 2014 at 11:41:18PM +0200, Christian Engelmayer wrote:
> In case allocation via usb_alloc_coherent() fails in ims_pcu_buffers_alloc(),
> the function jumps to the exit path without initializing local variable
> 'error' that is used as return value. Detected by Coverity - CID 1016531.
>
> Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Applied, thank you.
> ---
> This is an allocation function and all currently coded error scenarios
> result in -ENOMEM. Thus it would be possible to eliminate 'error' at all and
> always return -ENOMEM in the error path.
>
> Compile tested. Applies against branch next in tree
> git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
> ---
> drivers/input/misc/ims-pcu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
> index 5a73639..719410f 100644
> --- a/drivers/input/misc/ims-pcu.c
> +++ b/drivers/input/misc/ims-pcu.c
> @@ -1566,6 +1566,7 @@ static int ims_pcu_buffers_alloc(struct ims_pcu *pcu)
> if (!pcu->urb_ctrl_buf) {
> dev_err(pcu->dev,
> "Failed to allocate memory for read buffer\n");
> + error = -ENOMEM;
> goto err_free_urb_out_buf;
> }
>
> --
> 1.9.1
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-18 23:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-18 21:41 [PATCH] Input: ims-pcu - fix uninitialized use of 'error' in ims_pcu_buffers_alloc() Christian Engelmayer
2014-05-18 23:00 ` 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).