From: Antoine Tenart <antoine.tenart@free-electrons.com>
To: dan.carpenter@oracle.com
Cc: Antoine Tenart <antoine.tenart@free-electrons.com>,
sebastian.hesselbarth@gmail.com,
alexandre.belloni@free-electrons.com,
thomas.petazzoni@free-electrons.com, zmxu@marvell.com,
jszhang@marvell.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: pxa168_eth: avoid using signed char for bitops
Date: Fri, 3 Oct 2014 17:07:03 +0200 [thread overview]
Message-ID: <20141003150703.GA20398@kwain> (raw)
In-Reply-To: <1412348517-20352-2-git-send-email-antoine.tenart@free-electrons.com>
On Fri, Oct 03, 2014 at 05:01:54PM +0200, Antoine Tenart wrote:
> Signedness bugs may occur when using signed char for bitops,
> depending on if the highest bit is ever used.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>
> Dan reported a static checker warning:
> http://marc.info/?l=kernel-janitors&m=141218246222535&w=2
>
> This patch fixes it. Instead of using sa->sa_data we now use
> dev->dev_addr (of type unsigned char *) to avoid possible
> signedness issues.
Well, this patch shouldn't be in this thread. I'm resending it.
Sorry for the noise.
Antoine
>
> drivers/net/ethernet/marvell/pxa168_eth.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
> index 24de41231593..c3b209cd0660 100644
> --- a/drivers/net/ethernet/marvell/pxa168_eth.c
> +++ b/drivers/net/ethernet/marvell/pxa168_eth.c
> @@ -634,12 +634,12 @@ static int pxa168_eth_set_mac_address(struct net_device *dev, void *addr)
> memcpy(oldMac, dev->dev_addr, ETH_ALEN);
> memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
>
> - mac_h = sa->sa_data[0] << 24;
> - mac_h |= sa->sa_data[1] << 16;
> - mac_h |= sa->sa_data[2] << 8;
> - mac_h |= sa->sa_data[3];
> - mac_l = sa->sa_data[4] << 8;
> - mac_l |= sa->sa_data[5];
> + mac_h = dev->dev_addr[0] << 24;
> + mac_h |= dev->dev_addr[1] << 16;
> + mac_h |= dev->dev_addr[2] << 8;
> + mac_h |= dev->dev_addr[3];
> + mac_l = dev->dev_addr[4] << 8;
> + mac_l |= dev->dev_addr[5];
> wrl(pep, MAC_ADDR_HIGH, mac_h);
> wrl(pep, MAC_ADDR_LOW, mac_l);
>
> --
> 1.9.1
>
--
Antoine Ténart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2014-10-03 15:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 15:01 [PATCH 0/2] net: spider_net: fix possible bitops errors Antoine Tenart
2014-10-03 15:01 ` [PATCH] net: pxa168_eth: avoid using signed char for bitops Antoine Tenart
2014-10-03 15:07 ` Antoine Tenart [this message]
2014-10-03 15:01 ` [PATCH 1/2] net: spider_net: do not read mac address again after setting it Antoine Tenart
2014-10-03 15:01 ` [PATCH 2/2] net: spider_net: avoid using signed char for bitops Antoine Tenart
2014-10-03 15:15 ` Arnd Bergmann
2014-10-03 15:17 ` Antoine Tenart
2014-10-06 1:15 ` [PATCH 0/2] net: spider_net: fix possible bitops errors David Miller
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=20141003150703.GA20398@kwain \
--to=antoine.tenart@free-electrons.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=dan.carpenter@oracle.com \
--cc=jszhang@marvell.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=thomas.petazzoni@free-electrons.com \
--cc=zmxu@marvell.com \
/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 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).