From: Joe Perches <joe@perches.com>
To: Chengguang Xu <cgxu519@gmx.com>,
jakub.kicinski@netronome.com, davem@davemloft.net,
LKML <linux-kernel@vger.kernel.org>,
Julia Lawall <julia.lawall@lip6.fr>,
cocci <cocci@systeme.lip6.fr>
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input <linux-input@vger.kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>
Subject: Re: [PATCH v2 net] nfp: cast sizeof() to int when comparing with error code
Date: Mon, 25 Jun 2018 19:10:59 -0700 [thread overview]
Message-ID: <ff0b2834b771a467246b9f7c1b4600c38f5bb463.camel@perches.com> (raw)
In-Reply-To: <20180626011631.22717-1-cgxu519@gmx.com>
On Tue, 2018-06-26 at 09:16 +0800, Chengguang Xu wrote:
> sizeof() will return unsigned value so in the error check
> negative error code will be always larger than sizeof().
This looks like a general class of error in the kernel
where a signed result that could be returning a -errno
is tested against < or <= sizeof()
A couple examples:
drivers/input/mouse/elan_i2c_smbus.c:
len = i2c_smbus_read_block_data(client,
ETP_SMBUS_IAP_PASSWORD_READ,
val);
if (len < sizeof(u16)) {
i2c_smbus_read_block_data can return a negative errno
net/smc/smc_clc.c:
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
sizeof(struct smc_clc_msg_decline));
if (len < sizeof(struct smc_clc_msg_decline))
where kernel_sendmsg can return a negative errno
There are probably others, I didn't look hard.
Perhaps a cocci script to find these could be generated?
next parent reply other threads:[~2018-06-26 2:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180626011631.22717-1-cgxu519@gmx.com>
2018-06-26 2:10 ` Joe Perches [this message]
2018-06-26 7:21 ` Julia Lawall
2018-06-26 8:06 ` Julia Lawall
2018-06-26 8:21 ` cgxu519
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=ff0b2834b771a467246b9f7c1b4600c38f5bb463.camel@perches.com \
--to=joe@perches.com \
--cc=cgxu519@gmx.com \
--cc=cocci@systeme.lip6.fr \
--cc=davem@davemloft.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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
all inboxes | Powered by JetHome®