From: Salil Mehta <salil.mehta@huawei.com>
To: yuehaibing <yuehaibing@huawei.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"Zhuangyuzeng (Yisen)" <yisen.zhuang@huawei.com>,
"lipeng (Y)" <lipeng321@huawei.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH net-next] net: hns3: Fix potential NULL dereference on allocation error
Date: Mon, 28 Jan 2019 16:47:06 +0000 [thread overview]
Message-ID: <2ac4844616c6490284e91a0317e807a6@huawei.com> (raw)
In-Reply-To: <20190125031333.17196-1-yuehaibing@huawei.com>
> From: yuehaibing
> Sent: Friday, January 25, 2019 3:14 AM
> To: davem@davemloft.net; Zhuangyuzeng (Yisen) <yisen.zhuang@huawei.com>;
> Salil Mehta <salil.mehta@huawei.com>; lipeng (Y) <lipeng321@huawei.com>
> Cc: linux-kernel@vger.kernel.org; netdev@vger.kernel.org; yuehaibing <yuehaibing@huawei.com>
> Subject: [PATCH net-next] net: hns3: Fix potential NULL dereference on
> allocation error
>
> hclge_mac_update_stats_complete doesn't check for NULL
> returns of kcalloc, it may result in an Oops.
>
> Fixes: d174ea75c96a ("net: hns3: add statistics for PFC frames and MAC
> control frames")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index 64b1589..7971606 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -343,6 +343,9 @@ static int hclge_mac_update_stats_complete(struct
> hclge_dev *hdev, u32 desc_num)
> int ret;
>
> desc = kcalloc(desc_num, sizeof(struct hclge_desc), GFP_KERNEL);
> + if (!desc)
> + return -ENOMEM;
> +
looks good to me.
Reviewed-by: Salil Mehta <salil.mehta@huawei.com>
next prev parent reply other threads:[~2019-01-28 16:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 3:13 [PATCH net-next] net: hns3: Fix potential NULL dereference on allocation error YueHaibing
2019-01-28 16:47 ` Salil Mehta [this message]
2019-02-01 3:15 ` YueHaibing
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=2ac4844616c6490284e91a0317e807a6@huawei.com \
--to=salil.mehta@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=yisen.zhuang@huawei.com \
--cc=yuehaibing@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