I think smatch has a regression in the unused return check. I've tested following (Linux 4.3; config attached): rm net/batman-adv/bat_iv_ogm.o; \ EXTRA_CFLAGS="-Werror -D__CHECK_ENDIAN__" make M=net/batman-adv CHECK="smatch -p=kernel --two-passes --file-output" CC="cgcc" ; \ cat net/batman-adv/bat_iv_ogm.c.smatch I tested following revisions with the "more_memory.patch" applied to avoid the "Function too hairy. Giving up" problems: * 0b78084aeb0004db657d6e2d4fa4c17ec9f2e8e5 - Failed with the message: net/batman-adv/bat_iv_ogm.c:1429 batadv_iv_ogm_process_per_outif warn: unused return: router_router = batadv_orig_router_get() * 8275cedc24555134f57d471e9db3612729374334 - no message It seems that 0b78084aeb0004db657d6e2d4fa4c17ec9f2e8e5 introduces a regression because router_router is used on line 1439, 1422, 1556 and 1557. Also reverting the commit 0b78084aeb0004db657d6e2d4fa4c17ec9f2e8e5 on the current master and applying the "more_memory.patch" fixes the problem here. Attached is also a simplified (ok, little bit braindead) version of the function which still shows the same symptom and can be compiled without the "more_memory.patch".
Attachment:
.config
Description: Binary data
/* Copyright (C) 2007-2015 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "bat_algo.h" #include "main.h" #include <linux/atomic.h> #include <linux/bitmap.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/byteorder/generic.h> #include <linux/cache.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/fs.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/jiffies.h> #include <linux/list.h> #include <linux/netdevice.h> #include <linux/pkt_sched.h> #include <linux/printk.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/rcupdate.h> #include <linux/seq_file.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/stddef.h> #include <linux/string.h> #include <linux/types.h> #include <linux/workqueue.h> #include "bitarray.h" #include "hard-interface.h" #include "hash.h" #include "network-coding.h" #include "originator.h" #include "packet.h" #include "routing.h" #include "send.h" #include "translation-table.h" void batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, struct batadv_orig_node *orig_node, struct batadv_hard_iface *if_incoming, struct batadv_hard_iface *if_outgoing) { struct batadv_neigh_node *router = NULL; struct batadv_neigh_node *router_router = NULL; struct batadv_neigh_ifinfo *router_ifinfo = NULL; router = batadv_orig_router_get(orig_node, if_outgoing); if (router) { router_router = batadv_orig_router_get(router->orig_node, if_outgoing); router_ifinfo = batadv_neigh_ifinfo_get(router, if_outgoing); } if (router_ifinfo) { printk("bar\n"); batadv_neigh_ifinfo_free_ref(router_ifinfo); } /* avoid temporary routing loops */ if (router && router_router) printk("foo\n"); if (router) batadv_neigh_node_free_ref(router); if (router_router) batadv_neigh_node_free_ref(router_router); }
diff --git a/smatch_slist.c b/smatch_slist.c index 55becc9..7f83e9c 100644 --- a/smatch_slist.c +++ b/smatch_slist.c @@ -237,7 +237,7 @@ int out_of_memory(void) * It works out OK for the kernel and so it should work * for most other projects as well. */ - if (sm_state_counter * sizeof(struct sm_state) >= 50000000) + if (sm_state_counter * sizeof(struct sm_state) >= 300000000) return 1; return 0; }