提交 fd07a62d 编写于 作者: C Colin Ian King 提交者: David S. Miller

net: hns3: ensure media_type is unitialized

Media type is only set if h->ae_algo->ops->get_media_type is called
so there is a possibility that media_type is uninitialized when it is
used a switch statement.  Fix this by initializing media_type to
HNAE3_MEDIA_TYPE_UNKNOWN.

Detected by CoverityScan, CID#1452624("Uninitialized scalar variable")

Fixes: 496d03e9 ("net: hns3: Add Ethtool support to HNS3 driver")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 93345c06
......@@ -304,7 +304,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
struct hnae3_handle *h = priv->ae_handle;
u32 supported_caps;
u32 advertised_caps;
u8 media_type;
u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
u8 link_stat;
u8 auto_neg;
u8 duplex;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册