Skip to content

Commit

Permalink
batman-adv: properly check pskb_may_pull return value
Browse files Browse the repository at this point in the history
pskb_may_pull() returns 1 on success and 0 in case of failure,
therefore checking for the return value being negative does
not make sense at all.

This way if the function fails we will probably read beyond the current
skb data buffer. Fix this by doing the proper check.

Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
  • Loading branch information
Antonio Quartulli committed Feb 17, 2014
1 parent 91c2b1a commit f179142
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
int is_old_ttvn;

/* check if there is enough data before accessing it */
if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
if (!pskb_may_pull(skb, hdr_len + ETH_HLEN))
return 0;

/* create a copy of the skb (in case of for re-routing) to modify it. */
Expand Down

0 comments on commit f179142

Please sign in to comment.