From: "Hans J. Koch" <hjk@hansjkoch.de>
To: Vitalii Demianets <vitas@nppfactor.kiev.ua>
Cc: linux-kernel@vger.kernel.org, "Hans J. Koch" <hjk@hansjkoch.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] uio.c: Fix warning: 'ret' might be used uninitialized
Date: Tue, 27 Nov 2012 23:43:41 +0100 [thread overview]
Message-ID: <20121127224341.GA2605@local> (raw)
In-Reply-To: <201211271348.14603.vitas@nppfactor.kiev.ua>
On Tue, Nov 27, 2012 at 01:48:14PM +0200, Vitalii Demianets wrote:
> Fix warning: 'ret' might be used uninitialized
>
> Signed-off-by: Vitalii Demianets <vitas@nppfactor.kiev.ua>
> ---
> drivers/uio/uio.c | 16 ++++++++++++----
> 1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index 5110f36..c33fd18 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -280,12 +280,16 @@ static int uio_dev_add_attributes(struct uio_device *idev)
> map_found = 1;
> idev->map_dir = kobject_create_and_add("maps",
> &idev->dev->kobj);
> - if (!idev->map_dir)
> + if (!idev->map_dir) {
> + ret = -ENOMEM;
> goto err_map;
> + }
> }
> map = kzalloc(sizeof(*map), GFP_KERNEL);
> - if (!map)
> + if (!map) {
> + ret = -ENOMEM;
> goto err_map;
> + }
> kobject_init(&map->kobj, &map_attr_type);
> map->mem = mem;
> mem->map = map;
> @@ -305,12 +309,16 @@ static int uio_dev_add_attributes(struct uio_device *idev)
> portio_found = 1;
> idev->portio_dir = kobject_create_and_add("portio",
> &idev->dev->kobj);
> - if (!idev->portio_dir)
> + if (!idev->portio_dir) {
> + ret = -ENOMEM;
> goto err_portio;
> + }
> }
> portio = kzalloc(sizeof(*portio), GFP_KERNEL);
> - if (!portio)
> + if (!portio) {
> + ret = -ENOMEM;
> goto err_portio;
> + }
> kobject_init(&portio->kobj, &portio_attr_type);
> portio->port = port;
> port->portio = portio;
> --
> 1.7.8.6
>
Thanks, good catch, but why don't you simply do this:
>From 228445996bb75a44d16b6237eca6a0916d9b2d7e Mon Sep 17 00:00:00 2001
From: "Hans J. Koch" <hjk@hansjkoch.de>
Date: Tue, 27 Nov 2012 23:38:00 +0100
Subject: [PATCH] uio: Fix warning: 'ret' might be used uninitialized
In two cases, the return value variable "ret" can be undefined.
Signed-off-by: Hans J. Koch <hjk@hansjkoch.de>
---
drivers/uio/uio.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 5110f36..fc60e35 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -263,7 +263,7 @@ static struct class uio_class = {
*/
static int uio_dev_add_attributes(struct uio_device *idev)
{
- int ret;
+ int ret = -ENOMEM;
int mi, pi;
int map_found = 0;
int portio_found = 0;
--
1.7.9
next prev parent reply other threads:[~2012-11-27 22:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 11:48 [PATCH] uio.c: Fix warning: 'ret' might be used uninitialized Vitalii Demianets
2012-11-27 12:24 ` Vitalii Demianets
2012-11-27 22:43 ` Hans J. Koch [this message]
2012-11-28 8:58 ` Vitalii Demianets
2012-11-28 21:05 ` Hans J. Koch
2012-11-29 16:05 ` Tux9
2012-11-29 16:22 ` Vitalii Demianets
2012-11-29 16:33 ` Cong Ding
2012-11-29 16:36 ` Vitalii Demianets
2012-11-29 23:58 ` Hans J. Koch
2012-11-30 11:12 ` Tux9
2012-11-30 21:33 ` Hans J. Koch
2012-12-01 1:22 ` Cong Ding
2012-12-01 3:56 ` Hans J. Koch
2012-12-01 9:58 ` Cong Ding
2012-12-03 7:51 ` Hans J. Koch
2012-11-30 11:16 ` Vitalii Demianets
2012-11-30 21:39 ` Hans J. Koch
2012-11-30 23:43 ` Greg Kroah-Hartman
2012-12-03 7:41 ` [PATCH] stable: uio: " Hans J. Koch
2012-12-03 13:38 ` Ben Hutchings
2012-12-03 8:35 ` [PATCH] uio.c: " Vitalii Demianets
2012-12-03 8:53 ` Vitalii Demianets
2012-12-03 17:27 ` Hans J. Koch
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=20121127224341.GA2605@local \
--to=hjk@hansjkoch.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vitas@nppfactor.kiev.ua \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.