linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource()
@ 2021-06-05  2:31 Yang Yingliang
  2021-06-06  1:02 ` Vladimir Oltean
  2021-06-07 21:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2021-06-05  2:31 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>
---
v2:
  add missing goto err_alloc_felix
---
 drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
index 84f93a874d50..deae923c8b7a 100644
--- a/drivers/net/dsa/ocelot/seville_vsc9953.c
+++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
@@ -1206,6 +1206,11 @@ 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");
+		goto err_alloc_felix;
+	}
 	felix->switch_base = res->start;
 
 	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);
-- 
2.25.1


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

* Re: [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource()
  2021-06-05  2:31 [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource() Yang Yingliang
@ 2021-06-06  1:02 ` Vladimir Oltean
  2021-06-07 21:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2021-06-06  1:02 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, netdev, vladimir.oltean, davem, kuba

On Sat, Jun 05, 2021 at 10:31:48AM +0800, Yang Yingliang wrote:
> 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>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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

* Re: [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource()
  2021-06-05  2:31 [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource() Yang Yingliang
  2021-06-06  1:02 ` Vladimir Oltean
@ 2021-06-07 21:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-07 21:10 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, netdev, vladimir.oltean, davem, kuba

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Sat, 5 Jun 2021 10:31:48 +0800 you wrote:
> 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>
> ---
> v2:
>   add missing goto err_alloc_felix
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: mscc: ocelot: check return value after calling platform_get_resource()
    https://git.kernel.org/netdev/net-next/c/f1fe19c2cb3f

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05  2:31 [PATCH net-next v2] net: mscc: ocelot: check return value after calling platform_get_resource() Yang Yingliang
2021-06-06  1:02 ` Vladimir Oltean
2021-06-07 21:10 ` patchwork-bot+netdevbpf

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