linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v1] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap
@ 2016-12-13 14:34 Arvind Yadav
  2016-12-14 14:40 ` kbuild test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2016-12-13 14:34 UTC (permalink / raw)
  To: peter.chen, fw; +Cc: netdev, linux-kernel

Here, If devm_ioremap will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference.
This error check will avoid NULL pointer dereference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index 4ab404f..4d9528f 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -1479,6 +1479,12 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
 	p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size);
 	p->agl_prt_ctl = (u64)devm_ioremap(&pdev->dev, p->agl_prt_ctl_phys,
 					   p->agl_prt_ctl_size);
+	if (!p->mix || !p->agl || !p->agl_prt_ctl) {
+		dev_err(dev, "failed to map I/O memory\n");
+		result = -ENOMEM;
+		goto err;
+	}
+
 	spin_lock_init(&p->lock);
 
 	skb_queue_head_init(&p->tx_list);
-- 
2.7.4

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

* Re: [v1] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap
  2016-12-13 14:34 [v1] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap Arvind Yadav
@ 2016-12-14 14:40 ` kbuild test robot
  2016-12-14 16:30   ` arvind Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: kbuild test robot @ 2016-12-14 14:40 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: kbuild-all, peter.chen, fw, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

Hi Arvind,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.9 next-20161214]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/net-ethernet-cavium-octeon-octeon_mgmt-Handle-return-NULL-error-from-devm_ioremap/20161213-224624
config: mips-cavium_octeon_defconfig (attached as .config)
compiler: mips64-linux-gnuabi64-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/cavium/octeon/octeon_mgmt.c: In function 'octeon_mgmt_probe':
>> drivers/net/ethernet/cavium/octeon/octeon_mgmt.c:1473:11: error: 'dev' undeclared (first use in this function)
      dev_err(dev, "failed to map I/O memory\n");
              ^~~
   drivers/net/ethernet/cavium/octeon/octeon_mgmt.c:1473:11: note: each undeclared identifier is reported only once for each function it appears in

vim +/dev +1473 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c

  1467	
  1468		p->mix = (u64)devm_ioremap(&pdev->dev, p->mix_phys, p->mix_size);
  1469		p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size);
  1470		p->agl_prt_ctl = (u64)devm_ioremap(&pdev->dev, p->agl_prt_ctl_phys,
  1471						   p->agl_prt_ctl_size);
  1472		if (!p->mix || !p->agl || !p->agl_prt_ctl) {
> 1473			dev_err(dev, "failed to map I/O memory\n");
  1474			result = -ENOMEM;
  1475			goto err;
  1476		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 15718 bytes --]

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

* Re: [v1] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap
  2016-12-14 14:40 ` kbuild test robot
@ 2016-12-14 16:30   ` arvind Yadav
  0 siblings, 0 replies; 3+ messages in thread
From: arvind Yadav @ 2016-12-14 16:30 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, peter.chen, fw, netdev, linux-kernel

Sorry for build failure. I have send new changes. Which does not
this failure.

Thanks
-Arvind

On Wednesday 14 December 2016 08:10 PM, kbuild test robot wrote:
> Hi Arvind,
>
> [auto build test ERROR on net-next/master]
> [also build test ERROR on v4.9 next-20161214]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/net-ethernet-cavium-octeon-octeon_mgmt-Handle-return-NULL-error-from-devm_ioremap/20161213-224624
> config: mips-cavium_octeon_defconfig (attached as .config)
> compiler: mips64-linux-gnuabi64-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
>          wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # save the attached .config to linux build tree
>          make.cross ARCH=mips
>
> All errors (new ones prefixed by >>):
>
>     drivers/net/ethernet/cavium/octeon/octeon_mgmt.c: In function 'octeon_mgmt_probe':
>>> drivers/net/ethernet/cavium/octeon/octeon_mgmt.c:1473:11: error: 'dev' undeclared (first use in this function)
>        dev_err(dev, "failed to map I/O memory\n");
>                ^~~
>     drivers/net/ethernet/cavium/octeon/octeon_mgmt.c:1473:11: note: each undeclared identifier is reported only once for each function it appears in
>
> vim +/dev +1473 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
>
>    1467	
>    1468		p->mix = (u64)devm_ioremap(&pdev->dev, p->mix_phys, p->mix_size);
>    1469		p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size);
>    1470		p->agl_prt_ctl = (u64)devm_ioremap(&pdev->dev, p->agl_prt_ctl_phys,
>    1471						   p->agl_prt_ctl_size);
>    1472		if (!p->mix || !p->agl || !p->agl_prt_ctl) {
>> 1473			dev_err(dev, "failed to map I/O memory\n");
>    1474			result = -ENOMEM;
>    1475			goto err;
>    1476		}
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

end of thread, other threads:[~2016-12-14 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 14:34 [v1] net:ethernet:cavium:octeon:octeon_mgmt: Handle return NULL error from devm_ioremap Arvind Yadav
2016-12-14 14:40 ` kbuild test robot
2016-12-14 16:30   ` arvind Yadav

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