diff options
author | Neil Horman <nhorman@redhat.com> | 2015-07-21 09:55:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-22 21:19:17 -0700 |
commit | 513e1cbda230c626bc01492f440805c4a88632d7 (patch) | |
tree | 293b27e1bf8dff37b35905ef3775b50eaa4b9784 /drivers/staging | |
parent | 998ff7f85d2a4923cf8e49319957bb2a70f8b881 (diff) |
staging: unisys: Linarize skbs
If we can't fit an skb into a frag array, linaraize it so we don't have to
Signed-off-by: Neil Horman <nhorman@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/unisys/visornic/visornic_main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index f7363925f4a1..a421a5bea343 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -221,9 +221,25 @@ visor_copy_fragsinfo_from_skb(struct sk_buff *skb, unsigned int firstfraglen, struct phys_info frags[]) { unsigned int count = 0, ii, size, offset = 0, numfrags; + unsigned int total_count; numfrags = skb_shinfo(skb)->nr_frags; + /* + * Compute the number of fragments this skb has, and if its more than + * frag array can hold, linearize the skb + */ + total_count = numfrags + (firstfraglen / PI_PAGE_SIZE); + if (firstfraglen % PI_PAGE_SIZE) + total_count++; + + if (total_count > frags_max) { + if (skb_linearize(skb)) + return -EINVAL; + numfrags = skb_shinfo(skb)->nr_frags; + firstfraglen = 0; + } + while (firstfraglen) { if (count == frags_max) return -EINVAL; |