* [PATCH][net-next] net: hns3: ensure media_type is unitialized
@ 2017-08-17 9:01 Colin King
2017-08-17 17:06 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-08-17 9:01 UTC (permalink / raw)
To: Yisen Zhuang, Salil Mehta, Daode Huang, David S . Miller, lipeng,
netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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: 496d03e960ae ("net: hns3: Add Ethtool support to HNS3 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 0ad65e47c77e..53cab3ad4cda 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -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;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH][net-next] net: hns3: ensure media_type is unitialized
2017-08-17 9:01 [PATCH][net-next] net: hns3: ensure media_type is unitialized Colin King
@ 2017-08-17 17:06 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-08-17 17:06 UTC (permalink / raw)
To: colin.king
Cc: yisen.zhuang, salil.mehta, huangdaode, lipeng321, netdev,
kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Thu, 17 Aug 2017 10:01:07 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> 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: 496d03e960ae ("net: hns3: Add Ethtool support to HNS3 driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-17 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 9:01 [PATCH][net-next] net: hns3: ensure media_type is unitialized Colin King
2017-08-17 17:06 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox