All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.4] net: moxa: Use devm_platform_get_and_ioremap_resource()
@ 2021-07-16  9:32 Yang Yingliang
  2021-07-19 12:40 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-07-16  9:32 UTC (permalink / raw)
  To: sudipm.mukherjee, gregkh; +Cc: linux-kernel, stable, davem, sashal

[ Upstream commit 35cba15a504bf4f585bb9d78f47b22b28a1a06b2 ]

Use devm_platform_get_and_ioremap_resource() to simplify
code and avoid a null-ptr-deref by checking 'res' in it.

[yyl: since devm_platform_get_and_ioremap_resource() is introduced
      in linux-5.7, so just check the return value after calling
      platform_get_resource()]

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/ethernet/moxa/moxart_ether.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index f70bb81e1ed65..caf7051302725 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -481,6 +481,10 @@ static int moxart_mac_probe(struct platform_device *pdev)
 	priv->pdev = pdev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		ret = -EINVAL;
+		goto init_fail;
+	}
 	ndev->base_addr = res->start;
 	priv->base = devm_ioremap_resource(p_dev, res);
 	if (IS_ERR(priv->base)) {
-- 
2.25.1


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

* Re: [PATCH 5.4] net: moxa: Use devm_platform_get_and_ioremap_resource()
  2021-07-16  9:32 [PATCH 5.4] net: moxa: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
@ 2021-07-19 12:40 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-07-19 12:40 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: sudipm.mukherjee, linux-kernel, stable, davem, sashal

On Fri, Jul 16, 2021 at 05:32:45PM +0800, Yang Yingliang wrote:
> [ Upstream commit 35cba15a504bf4f585bb9d78f47b22b28a1a06b2 ]
> 
> Use devm_platform_get_and_ioremap_resource() to simplify
> code and avoid a null-ptr-deref by checking 'res' in it.
> 
> [yyl: since devm_platform_get_and_ioremap_resource() is introduced
>       in linux-5.7, so just check the return value after calling
>       platform_get_resource()]
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  drivers/net/ethernet/moxa/moxart_ether.c | 4 ++++
>  1 file changed, 4 insertions(+)

Now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2021-07-19 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  9:32 [PATCH 5.4] net: moxa: Use devm_platform_get_and_ioremap_resource() Yang Yingliang
2021-07-19 12:40 ` Greg KH

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.