netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: hns3: Fix potential NULL dereference on allocation error
@ 2019-01-25  3:13 YueHaibing
  2019-01-28 16:47 ` Salil Mehta
  2019-02-01  3:15 ` YueHaibing
  0 siblings, 2 replies; 3+ messages in thread
From: YueHaibing @ 2019-01-25  3:13 UTC (permalink / raw)
  To: davem, yisen.zhuang, salil.mehta, lipeng321
  Cc: linux-kernel, netdev, YueHaibing

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;
+
 	hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_STATS_MAC_ALL, true);
 	ret = hclge_cmd_send(&hdev->hw, desc, desc_num);
 	if (ret) {
-- 
2.7.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next] net: hns3: Fix potential NULL dereference on allocation error
  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
  2019-02-01  3:15 ` YueHaibing
  1 sibling, 0 replies; 3+ messages in thread
From: Salil Mehta @ 2019-01-28 16:47 UTC (permalink / raw)
  To: yuehaibing, davem, Zhuangyuzeng (Yisen), lipeng (Y); +Cc: linux-kernel, netdev

> 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>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: hns3: Fix potential NULL dereference on allocation error
  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
@ 2019-02-01  3:15 ` YueHaibing
  1 sibling, 0 replies; 3+ messages in thread
From: YueHaibing @ 2019-02-01  3:15 UTC (permalink / raw)
  To: davem, yisen.zhuang, salil.mehta, lipeng321; +Cc: linux-kernel, netdev

ping ...

On 2019/1/25 11:13, YueHaibing wrote:
> 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;
> +
>  	hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_STATS_MAC_ALL, true);
>  	ret = hclge_cmd_send(&hdev->hw, desc, desc_num);
>  	if (ret) {
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-01  3:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-02-01  3:15 ` YueHaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).