* [PATCH] kcm: fix variable type
@ 2016-03-11 6:51 Andrzej Hajda
2016-03-11 16:44 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Hajda @ 2016-03-11 6:51 UTC (permalink / raw)
To: Tom Herbert
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
David S. Miller, netdev, linux-kernel
Function skb_splice_bits can return negative values, its result should
be assigned to signed variable to allow correct error checking.
The problem has been detected using patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
net/kcm/kcmsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 40662d73..0b68ba7 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1483,7 +1483,7 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,
long timeo;
struct kcm_rx_msg *rxm;
int err = 0;
- size_t copied;
+ ssize_t copied;
struct sk_buff *skb;
/* Only support splice for SOCKSEQPACKET */
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kcm: fix variable type
2016-03-11 6:51 [PATCH] kcm: fix variable type Andrzej Hajda
@ 2016-03-11 16:44 ` David Miller
2016-03-14 6:45 ` Andrzej Hajda
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2016-03-11 16:44 UTC (permalink / raw)
To: a.hajda; +Cc: tom, b.zolnierkie, m.szyprowski, netdev, linux-kernel
From: Andrzej Hajda <a.hajda@samsung.com>
Date: Fri, 11 Mar 2016 07:51:15 +0100
> Function skb_splice_bits can return negative values, its result should
> be assigned to signed variable to allow correct error checking.
>
> The problem has been detected using patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Since skb_splice_bits() returns an 'int', that would be a more appropriate
type to use here.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kcm: fix variable type
2016-03-11 16:44 ` David Miller
@ 2016-03-14 6:45 ` Andrzej Hajda
0 siblings, 0 replies; 3+ messages in thread
From: Andrzej Hajda @ 2016-03-14 6:45 UTC (permalink / raw)
To: David Miller; +Cc: tom, b.zolnierkie, m.szyprowski, netdev, linux-kernel
On 03/11/2016 05:44 PM, David Miller wrote:
> From: Andrzej Hajda <a.hajda@samsung.com>
> Date: Fri, 11 Mar 2016 07:51:15 +0100
>
>> Function skb_splice_bits can return negative values, its result should
>> be assigned to signed variable to allow correct error checking.
>>
>> The problem has been detected using patch
>> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Since skb_splice_bits() returns an 'int', that would be a more appropriate
> type to use here.
>
> Thank you.
>
>
On the other side kcm_splice_read use this local var as return variable,
and the return type is ssize_t.
Digging deeper it looks like:
ssize_t kcm_splice_read(...) returns result of
int skb_splice_bits(...) which returns result of
ssize_t splice_cb(...) callback.
It looks code is somehow inconsistent, but maybe there are other reasons
which I am not aware of.
Regards
Andrzej
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-14 6:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 6:51 [PATCH] kcm: fix variable type Andrzej Hajda
2016-03-11 16:44 ` David Miller
2016-03-14 6:45 ` Andrzej Hajda
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).