mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
tipc: Fix backport of b774134464
Clang warns:
net/tipc/link.c:896:23: warning: variable 'hdr' is uninitialized when
used here [-Wuninitialized]
imp = msg_importance(hdr);
^~~
net/tipc/link.c:890:22: note: initialize the variable 'hdr' to silence
this warning
struct tipc_msg *hdr;
^
= NULL
1 warning generated.
The backport of commit b774134464 ("tipc: fix NULL deref in
tipc_link_xmit()") to 4.9 as commit 310014f572 ("tipc: fix NULL deref
in tipc_link_xmit()") added the hdr initialization above the
if (unlikely(msg_size(hdr) > mtu)) {
like in the upstream commit; however, in 4.9, that check is below imp's
first use because commit 365ad353c2 ("tipc: reduce risk of user
starvation during link congestion") is not present. This results in hdr
being used uninitialized.
Fix this by moving hdr's initialization before imp and after the if
check like the original backport did.
Cc: Hoang Le <hoang.h.le@dektech.com.au>
Cc: Jon Maloy <jon.maloy@ericsson.com>
Cc: Ying Xue <ying.xue@windriver.com>
Fixes: 310014f572 ("tipc: fix NULL deref in tipc_link_xmit()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
@@ -893,6 +893,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
|
||||
if (pkt_cnt <= 0)
|
||||
return 0;
|
||||
|
||||
hdr = buf_msg(skb_peek(list));
|
||||
imp = msg_importance(hdr);
|
||||
/* Match msg importance against this and all higher backlog limits: */
|
||||
if (!skb_queue_empty(backlogq)) {
|
||||
@@ -902,7 +903,6 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,
|
||||
}
|
||||
}
|
||||
|
||||
hdr = buf_msg(skb_peek(list));
|
||||
if (unlikely(msg_size(hdr) > mtu)) {
|
||||
skb_queue_purge(list);
|
||||
return -EMSGSIZE;
|
||||
|
||||
Reference in New Issue
Block a user