Correct .gbs.conf settings
[platform/adaptation/renesas_rcar/renesas_kernel.git] / net / batman-adv / fragmentation.c
index 6ddb614..c46387a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013 B.A.T.M.A.N. contributors:
+/* Copyright (C) 2013-2014 B.A.T.M.A.N. contributors:
  *
  * Martin Hundebøll <martin@hundeboll.net>
  *
@@ -12,9 +12,7 @@
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "main.h"
@@ -130,6 +128,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
 {
        struct batadv_frag_table_entry *chain;
        struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr;
+       struct batadv_frag_list_entry *frag_entry_last = NULL;
        struct batadv_frag_packet *frag_packet;
        uint8_t bucket;
        uint16_t seqno, hdr_size = sizeof(struct batadv_frag_packet);
@@ -182,11 +181,14 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
                        ret = true;
                        goto out;
                }
+
+               /* store current entry because it could be the last in list */
+               frag_entry_last = frag_entry_curr;
        }
 
-       /* Reached the end of the list, so insert after 'frag_entry_curr'. */
-       if (likely(frag_entry_curr)) {
-               hlist_add_after(&frag_entry_curr->list, &frag_entry_new->list);
+       /* Reached the end of the list, so insert after 'frag_entry_last'. */
+       if (likely(frag_entry_last)) {
+               hlist_add_after(&frag_entry_last->list, &frag_entry_new->list);
                chain->size += skb->len - hdr_size;
                chain->timestamp = jiffies;
                ret = true;
@@ -420,12 +422,13 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
                             struct batadv_neigh_node *neigh_node)
 {
        struct batadv_priv *bat_priv;
-       struct batadv_hard_iface *primary_if;
+       struct batadv_hard_iface *primary_if = NULL;
        struct batadv_frag_packet frag_header;
        struct sk_buff *skb_fragment;
        unsigned mtu = neigh_node->if_incoming->net_dev->mtu;
        unsigned header_size = sizeof(frag_header);
        unsigned max_fragment_size, max_packet_size;
+       bool ret = false;
 
        /* To avoid merge and refragmentation at next-hops we never send
         * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
@@ -485,7 +488,11 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
                           skb->len + ETH_HLEN);
        batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
 
-       return true;
+       ret = true;
+
 out_err:
-       return false;
+       if (primary_if)
+               batadv_hardif_free_ref(primary_if);
+
+       return ret;
 }