From: Colin King <colin.king@canonical.com>
To: Yisen Zhuang <yisen.zhuang@huawei.com>,
Salil Mehta <salil.mehta@huawei.com>,
Daode Huang <huangdaode@hisilicon.com>,
"David S . Miller" <davem@davemloft.net>,
lipeng <lipeng321@huawei.com>,
netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][net-next] net: hns3: ensure media_type is unitialized
Date: Thu, 17 Aug 2017 10:01:07 +0100 [thread overview]
Message-ID: <20170817090107.14310-1-colin.king@canonical.com> (raw)
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
next reply other threads:[~2017-08-17 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 9:01 Colin King [this message]
2017-08-17 17:06 ` [PATCH][net-next] net: hns3: ensure media_type is unitialized David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170817090107.14310-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=huangdaode@hisilicon.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox