linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] dvb: avoid warning in dvb_net
@ 2016-10-27 13:57 Arnd Bergmann
  2016-10-27 14:13 ` Jarod Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2016-10-27 13:57 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Arnd Bergmann, Hans Verkuil, Jarod Wilson, linux-media, linux-kernel

With gcc-5 or higher on x86, we can get a bogus warning in the
dvb-net code:

drivers/media/dvb-core/dvb_net.c: In function ‘dvb_net_ule’:
arch/x86/include/asm/string_32.h:77:14: error: ‘dest_addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/media/dvb-core/dvb_net.c:633:8: note: ‘dest_addr’ was declared here

The problem here is that gcc doesn't track all of the conditions
to prove it can't end up copying uninitialized data.
This changes the logic around so we zero out the destination
address earlier when we determine that it is not set here.
This allows the compiler to figure it out.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/dvb-core/dvb_net.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index 088914c4623f..f1b416de9dab 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -688,6 +688,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
 							      ETH_ALEN);
 						skb_pull(priv->ule_skb, ETH_ALEN);
 					}
+				} else {
+					 /* othersie use zero destination address */
+					eth_zero_addr(dest_addr);
 				}
 
 				/* Handle ULE Extension Headers. */
@@ -715,13 +718,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
 				if (!priv->ule_bridged) {
 					skb_push(priv->ule_skb, ETH_HLEN);
 					ethh = (struct ethhdr *)priv->ule_skb->data;
-					if (!priv->ule_dbit) {
-						 /* dest_addr buffer is only valid if priv->ule_dbit == 0 */
-						memcpy(ethh->h_dest, dest_addr, ETH_ALEN);
-						eth_zero_addr(ethh->h_source);
-					}
-					else /* zeroize source and dest */
-						memset( ethh, 0, ETH_ALEN*2 );
+					memcpy(ethh->h_dest, dest_addr, ETH_ALEN);
+					eth_zero_addr(ethh->h_source);
 
 					ethh->h_proto = htons(priv->ule_sndu_type);
 				}
-- 
2.9.0

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

* Re: [PATCH] [media] dvb: avoid warning in dvb_net
  2016-10-27 13:57 [PATCH] [media] dvb: avoid warning in dvb_net Arnd Bergmann
@ 2016-10-27 14:13 ` Jarod Wilson
  2016-10-27 15:09   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Jarod Wilson @ 2016-10-27 14:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel

On Thu, Oct 27, 2016 at 03:57:41PM +0200, Arnd Bergmann wrote:
> With gcc-5 or higher on x86, we can get a bogus warning in the
> dvb-net code:
> 
> drivers/media/dvb-core/dvb_net.c: In function ‘dvb_net_ule’:
> arch/x86/include/asm/string_32.h:77:14: error: ‘dest_addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/media/dvb-core/dvb_net.c:633:8: note: ‘dest_addr’ was declared here
> 
> The problem here is that gcc doesn't track all of the conditions
> to prove it can't end up copying uninitialized data.
> This changes the logic around so we zero out the destination
> address earlier when we determine that it is not set here.
> This allows the compiler to figure it out.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/dvb-core/dvb_net.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
> index 088914c4623f..f1b416de9dab 100644
> --- a/drivers/media/dvb-core/dvb_net.c
> +++ b/drivers/media/dvb-core/dvb_net.c
> @@ -688,6 +688,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
>  							      ETH_ALEN);
>  						skb_pull(priv->ule_skb, ETH_ALEN);
>  					}
> +				} else {
> +					 /* othersie use zero destination address */

I'm assuming you meant "otherwise" there instead of "othersie".

-- 
Jarod Wilson
jarod@redhat.com

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

* Re: [PATCH] [media] dvb: avoid warning in dvb_net
  2016-10-27 14:13 ` Jarod Wilson
@ 2016-10-27 15:09   ` Arnd Bergmann
  2016-10-27 15:25     ` Jarod Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2016-10-27 15:09 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel

On Thursday, October 27, 2016 10:13:27 AM CEST Jarod Wilson wrote:
> On Thu, Oct 27, 2016 at 03:57:41PM +0200, Arnd Bergmann wrote:
> > With gcc-5 or higher on x86, we can get a bogus warning in the
> > dvb-net code:
> > 
> > drivers/media/dvb-core/dvb_net.c: In function ‘dvb_net_ule’:
> > arch/x86/include/asm/string_32.h:77:14: error: ‘dest_addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > drivers/media/dvb-core/dvb_net.c:633:8: note: ‘dest_addr’ was declared here
> > 
> > The problem here is that gcc doesn't track all of the conditions
> > to prove it can't end up copying uninitialized data.
> > This changes the logic around so we zero out the destination
> > address earlier when we determine that it is not set here.
> > This allows the compiler to figure it out.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  drivers/media/dvb-core/dvb_net.c | 12 +++++-------
> >  1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
> > index 088914c4623f..f1b416de9dab 100644
> > --- a/drivers/media/dvb-core/dvb_net.c
> > +++ b/drivers/media/dvb-core/dvb_net.c
> > @@ -688,6 +688,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> >                                                             ETH_ALEN);
> >                                               skb_pull(priv->ule_skb, ETH_ALEN);
> >                                       }
> > +                             } else {
> > +                                      /* othersie use zero destination address */
> 
> I'm assuming you meant "otherwise" there instead of "othersie".
> 

Yes, I sent a v2 now, thanks for taking a look. I assume this means
you have no other objections to the patch?

	Arnd

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

* Re: [PATCH] [media] dvb: avoid warning in dvb_net
  2016-10-27 15:09   ` Arnd Bergmann
@ 2016-10-27 15:25     ` Jarod Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Jarod Wilson @ 2016-10-27 15:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel

On Thu, Oct 27, 2016 at 05:09:28PM +0200, Arnd Bergmann wrote:
> On Thursday, October 27, 2016 10:13:27 AM CEST Jarod Wilson wrote:
> > On Thu, Oct 27, 2016 at 03:57:41PM +0200, Arnd Bergmann wrote:
> > > With gcc-5 or higher on x86, we can get a bogus warning in the
> > > dvb-net code:
> > > 
> > > drivers/media/dvb-core/dvb_net.c: In function ‘dvb_net_ule’:
> > > arch/x86/include/asm/string_32.h:77:14: error: ‘dest_addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > > drivers/media/dvb-core/dvb_net.c:633:8: note: ‘dest_addr’ was declared here
> > > 
> > > The problem here is that gcc doesn't track all of the conditions
> > > to prove it can't end up copying uninitialized data.
> > > This changes the logic around so we zero out the destination
> > > address earlier when we determine that it is not set here.
> > > This allows the compiler to figure it out.
> > > 
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  drivers/media/dvb-core/dvb_net.c | 12 +++++-------
> > >  1 file changed, 5 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
> > > index 088914c4623f..f1b416de9dab 100644
> > > --- a/drivers/media/dvb-core/dvb_net.c
> > > +++ b/drivers/media/dvb-core/dvb_net.c
> > > @@ -688,6 +688,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> > >                                                             ETH_ALEN);
> > >                                               skb_pull(priv->ule_skb, ETH_ALEN);
> > >                                       }
> > > +                             } else {
> > > +                                      /* othersie use zero destination address */
> > 
> > I'm assuming you meant "otherwise" there instead of "othersie".
> > 
> 
> Yes, I sent a v2 now, thanks for taking a look. I assume this means
> you have no other objections to the patch?

No objections, but I don't know enough about ULE or it's handling there
to do an informed critique outside of the typo.

-- 
Jarod Wilson
jarod@redhat.com

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

end of thread, other threads:[~2016-10-27 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 13:57 [PATCH] [media] dvb: avoid warning in dvb_net Arnd Bergmann
2016-10-27 14:13 ` Jarod Wilson
2016-10-27 15:09   ` Arnd Bergmann
2016-10-27 15:25     ` Jarod Wilson

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).