[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2ac4844616c6490284e91a0317e807a6@huawei.com>
Date: Mon, 28 Jan 2019 16:47:06 +0000
From: Salil Mehta <salil.mehta@...wei.com>
To: yuehaibing <yuehaibing@...wei.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"Zhuangyuzeng (Yisen)" <yisen.zhuang@...wei.com>,
"lipeng (Y)" <lipeng321@...wei.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH net-next] net: hns3: Fix potential NULL dereference on
allocation error
> From: yuehaibing
> Sent: Friday, January 25, 2019 3:14 AM
> To: davem@...emloft.net; Zhuangyuzeng (Yisen) <yisen.zhuang@...wei.com>;
> Salil Mehta <salil.mehta@...wei.com>; lipeng (Y) <lipeng321@...wei.com>
> Cc: linux-kernel@...r.kernel.org; netdev@...r.kernel.org; yuehaibing <yuehaibing@...wei.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@...wei.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@...wei.com>
Powered by blists - more mailing lists