net: dm: check the boundary of skb drop reasons
authorMenglong Dong <imagedong@tencent.com>
Fri, 13 May 2022 03:03:36 +0000 (11:03 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 May 2022 09:47:43 +0000 (10:47 +0100)
commita3af33abd9210c93dc829b4fdd7a19f63f168a25
tree7f4c61b9ab4241fd95cb616c8d95ad56632687ec
parent3aba103006bcc4a7472b7c9506b3bc065ffb7992
net: dm: check the boundary of skb drop reasons

The 'reason' will be set to 'SKB_DROP_REASON_NOT_SPECIFIED' if it not
small that SKB_DROP_REASON_MAX in net_dm_packet_trace_kfree_skb_hit(),
but it can't avoid it to be 0, which is invalid and can cause NULL
pointer in drop_reasons.

Therefore, reset it to SKB_DROP_REASON_NOT_SPECIFIED when 'reason <= 0'.

Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/drop_monitor.c