2016-11-07 15:41:21

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] media: Fix get_key_haup_common.isra.4() debug message to print ptoggle value

Fix the debug message in get_key_haup_common.isra.4() doesn't print the
correct toggle value. Fix it. This shows up as an used uninitialized warn
message:

drivers/media/i2c/ir-kbd-i2c.c: In function ‘get_key_haup_common.isra.4’:
drivers/media/i2c/ir-kbd-i2c.c:62:2: warning: ‘toggle’ may be used uninitialized in this function [-Wmaybe-uninitialized]
printk(KERN_DEBUG MODULE_NAME ": " fmt , ## arg)
^~~~~~
drivers/media/i2c/ir-kbd-i2c.c:70:20: note: ‘toggle’ was declared here
int start, range, toggle, dev, code, ircode, vendor;
^~~~~~

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/media/i2c/ir-kbd-i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index f95a6bc..cede397 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -118,7 +118,7 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
*protocol = RC_TYPE_RC6_MCE;
dev &= 0x7f;
dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
- toggle, vendor, dev, code);
+ *ptoggle, vendor, dev, code);
} else {
*ptoggle = 0;
*protocol = RC_TYPE_RC6_6A_32;
--
2.9.3


2016-11-07 15:41:22

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] net/netfiliter: Fix used uninitialized warn in ip_vs_proc_sync_conn()

Fix the following warn:

net/netfilter/ipvs/ip_vs_sync.c: In function ‘ip_vs_proc_sync_conn’:
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
struct ip_vs_sync_conn_options opt;
^~~
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Shuah Khan <[email protected]>
---
fs/nfs/nfs4session.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index b629730..68e700e 100644
--- a/fs/nfs/nfs4session.c
+++ b/fs/nfs/nfs4session.c
@@ -196,7 +196,7 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
u32 slotid, u32 seq_nr)
{
- u32 cur_seq;
+ u32 cur_seq = 0;
bool ret = false;

spin_lock(&tbl->slot_tbl_lock);
--
2.9.3

2016-11-07 15:42:41

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] net/netfilter: Fix use uninitialized warn in nft_range_eval()

Fix the following warn:

CC [M] net/netfilter/nft_range.o
8601,8605c9105
net/netfilter/nft_range.c: In function ‘nft_range_eval’:
net/netfilter/nft_range.c:45:5: warning: ‘mismatch’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (mismatch)
^

Signed-off-by: Shuah Khan <[email protected]>
---
net/netfilter/nft_range.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
index c6d5358..fe5f69b 100644
--- a/net/netfilter/nft_range.c
+++ b/net/netfilter/nft_range.c
@@ -28,7 +28,7 @@ static void nft_range_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt)
{
const struct nft_range_expr *priv = nft_expr_priv(expr);
- bool mismatch;
+ bool mismatch = false;
int d1, d2;

d1 = memcmp(&regs->data[priv->sreg], &priv->data_from, priv->len);
--
2.9.3

2016-11-07 15:43:03

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] media: fix uninitialized variable warning in dib0700_rc_urb_completion()

Fix the following uninitialized variable compiler warning:

drivers/media/usb/dvb-usb/dib0700_core.c: In function ‘dib0700_rc_urb_completion’:
drivers/media/usb/dvb-usb/dib0700_core.c:763:2: warning: ‘protocol’ may be used uninitialized in this function [-Wmaybe-uninitialized]
rc_keydown(d->rc_dev, protocol, keycode, toggle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/media/usb/dvb-usb/dib0700_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index f319665..cfe28ec 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -676,7 +676,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
{
struct dvb_usb_device *d = purb->context;
struct dib0700_rc_response *poll_reply;
- enum rc_type protocol;
+ enum rc_type protocol = RC_TYPE_UNKNOWN;
u32 uninitialized_var(keycode);
u8 toggle;

--
2.9.3

2016-11-07 15:44:22

by Anna Schumaker

[permalink] [raw]
Subject: Re: [PATCH] net/netfiliter: Fix used uninitialized warn in ip_vs_proc_sync_conn()

Hi Shuah,

On 11/07/2016 10:41 AM, Shuah Khan wrote:
> Fix the following warn:
>
> net/netfilter/ipvs/ip_vs_sync.c: In function ‘ip_vs_proc_sync_conn’:
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> struct ip_vs_sync_conn_options opt;
> ^~~
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Are you sure you put the right commit message on this patch? The message describes a warning in ip_vs_sync.c, but the patch is for nfs4session.c.

Thanks,
Anna

>
> Signed-off-by: Shuah Khan <[email protected]>
> ---
> fs/nfs/nfs4session.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
> index b629730..68e700e 100644
> --- a/fs/nfs/nfs4session.c
> +++ b/fs/nfs/nfs4session.c
> @@ -196,7 +196,7 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
> static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
> u32 slotid, u32 seq_nr)
> {
> - u32 cur_seq;
> + u32 cur_seq = 0;
> bool ret = false;
>
> spin_lock(&tbl->slot_tbl_lock);
>

2016-11-07 16:15:09

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] net/netfiliter: Fix used uninitialized warn in ip_vs_proc_sync_conn()

On 11/07/2016 08:44 AM, Anna Schumaker wrote:
> Hi Shuah,
>
> On 11/07/2016 10:41 AM, Shuah Khan wrote:
>> Fix the following warn:
>>
>> net/netfilter/ipvs/ip_vs_sync.c: In function ‘ip_vs_proc_sync_conn’:
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> struct ip_vs_sync_conn_options opt;
>> ^~~
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘opt.previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).init_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>> net/netfilter/ipvs/ip_vs_sync.c:1069:33: warning: ‘*((void *)&opt+12).previous_delta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Are you sure you put the right commit message on this patch? The message describes a warning in ip_vs_sync.c, but the patch is for nfs4session.c.
>
> Thanks,
> Anna

Oops. Sorry about this. Bad cut and paste from make output.
I will resend the patch with the correct changelog

thanks,
-- Shuah

>
>>
>> Signed-off-by: Shuah Khan <[email protected]>
>> ---
>> fs/nfs/nfs4session.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
>> index b629730..68e700e 100644
>> --- a/fs/nfs/nfs4session.c
>> +++ b/fs/nfs/nfs4session.c
>> @@ -196,7 +196,7 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
>> static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
>> u32 slotid, u32 seq_nr)
>> {
>> - u32 cur_seq;
>> + u32 cur_seq = 0;
>> bool ret = false;
>>
>> spin_lock(&tbl->slot_tbl_lock);
>>
>

2016-11-08 11:23:48

by Sean Young

[permalink] [raw]
Subject: Re: [PATCH] media: fix uninitialized variable warning in dib0700_rc_urb_completion()

On Mon, Nov 07, 2016 at 08:41:12AM -0700, Shuah Khan wrote:
> Fix the following uninitialized variable compiler warning:
>
> drivers/media/usb/dvb-usb/dib0700_core.c: In function ‘dib0700_rc_urb_completion’:
> drivers/media/usb/dvb-usb/dib0700_core.c:763:2: warning: ‘protocol’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> rc_keydown(d->rc_dev, protocol, keycode, toggle);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Shuah Khan <[email protected]>
> ---
> drivers/media/usb/dvb-usb/dib0700_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
> index f319665..cfe28ec 100644
> --- a/drivers/media/usb/dvb-usb/dib0700_core.c
> +++ b/drivers/media/usb/dvb-usb/dib0700_core.c
> @@ -676,7 +676,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
> {
> struct dvb_usb_device *d = purb->context;
> struct dib0700_rc_response *poll_reply;
> - enum rc_type protocol;
> + enum rc_type protocol = RC_TYPE_UNKNOWN;
> u32 uninitialized_var(keycode);
> u8 toggle;
>

There is another (better) fix for it here:

https://patchwork.linuxtv.org/patch/37516/


Thanks
Sean

2016-11-08 23:13:58

by Pablo Neira Ayuso

[permalink] [raw]
Subject: Re: [PATCH] net/netfilter: Fix use uninitialized warn in nft_range_eval()

On Mon, Nov 07, 2016 at 08:41:14AM -0700, Shuah Khan wrote:
> Fix the following warn:
>
> CC [M] net/netfilter/nft_range.o
> 8601,8605c9105
> net/netfilter/nft_range.c: In function ‘nft_range_eval’:
> net/netfilter/nft_range.c:45:5: warning: ‘mismatch’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (mismatch)
> ^

You probably using an old tree snapshot? This was already fixed by:

commit d2e4d593516e877f1f6fb40031eb495f36606e16
Author: Arnd Bergmann <[email protected]>
Date: Tue Oct 18 00:05:30 2016 +0200

netfilter: nf_tables: avoid uninitialized variable warning

The newly added nft_range_eval() function handles the two possible
nft range operations, but as the compiler warning points out,
any unexpected value would lead to the 'mismatch' variable being
used without being initialized: