All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: mscc: ocelot: check return value after calling platform_get_resource()
@ 2021-06-04  9:32 Yang Yingliang
  2021-06-04 10:07 ` weiyongjun (A)
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-06-04  9:32 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: vladimir.oltean, davem, kuba

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/dsa/ocelot/seville_vsc9953.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
index 84f93a874d50..b514e2d05b6f 100644
--- a/drivers/net/dsa/ocelot/seville_vsc9953.c
+++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
@@ -1206,6 +1206,10 @@ static int seville_probe(struct platform_device *pdev)
 	felix->info = &seville_info_vsc9953;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		err = -EINVAL;
+		dev_err(&pdev->dev, "Invalid resource\n");
+	}
 	felix->switch_base = res->start;
 
 	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);
-- 
2.25.1


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

* Re: [PATCH net-next] net: mscc: ocelot: check return value after calling platform_get_resource()
  2021-06-04  9:32 [PATCH net-next] net: mscc: ocelot: check return value after calling platform_get_resource() Yang Yingliang
@ 2021-06-04 10:07 ` weiyongjun (A)
  0 siblings, 0 replies; 2+ messages in thread
From: weiyongjun (A) @ 2021-06-04 10:07 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, netdev; +Cc: vladimir.oltean, davem, kuba


> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/net/dsa/ocelot/seville_vsc9953.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
> index 84f93a874d50..b514e2d05b6f 100644
> --- a/drivers/net/dsa/ocelot/seville_vsc9953.c
> +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
> @@ -1206,6 +1206,10 @@ static int seville_probe(struct platform_device *pdev)
>   	felix->info = &seville_info_vsc9953;
>   
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res) {
> +		err = -EINVAL;
> +		dev_err(&pdev->dev, "Invalid resource\n");


should 'goto err_alloc_felix;'


> +	}
>   	felix->switch_base = res->start;
>   
>   	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);

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

end of thread, other threads:[~2021-06-04 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04  9:32 [PATCH net-next] net: mscc: ocelot: check return value after calling platform_get_resource() Yang Yingliang
2021-06-04 10:07 ` weiyongjun (A)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.