Browse Source

[intel] Check for ioremap() failures

Debugged-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
9ce2b56af6
2 changed files with 10 additions and 0 deletions
  1. 5
    0
      src/drivers/net/intel.c
  2. 5
    0
      src/drivers/net/intelx.c

+ 5
- 0
src/drivers/net/intel.c View File

819
 
819
 
820
 	/* Map registers */
820
 	/* Map registers */
821
 	intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
821
 	intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
822
+	if ( ! intel->regs ) {
823
+		rc = -ENODEV;
824
+		goto err_ioremap;
825
+	}
822
 
826
 
823
 	/* Reset the NIC */
827
 	/* Reset the NIC */
824
 	if ( ( rc = intel_reset ( intel ) ) != 0 )
828
 	if ( ( rc = intel_reset ( intel ) ) != 0 )
843
 	intel_reset ( intel );
847
 	intel_reset ( intel );
844
  err_reset:
848
  err_reset:
845
 	iounmap ( intel->regs );
849
 	iounmap ( intel->regs );
850
+ err_ioremap:
846
 	netdev_nullify ( netdev );
851
 	netdev_nullify ( netdev );
847
 	netdev_put ( netdev );
852
 	netdev_put ( netdev );
848
  err_alloc:
853
  err_alloc:

+ 5
- 0
src/drivers/net/intelx.c View File

400
 
400
 
401
 	/* Map registers */
401
 	/* Map registers */
402
 	intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
402
 	intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
403
+	if ( ! intel->regs ) {
404
+		rc = -ENODEV;
405
+		goto err_ioremap;
406
+	}
403
 
407
 
404
 	/* Reset the NIC */
408
 	/* Reset the NIC */
405
 	if ( ( rc = intelx_reset ( intel ) ) != 0 )
409
 	if ( ( rc = intelx_reset ( intel ) ) != 0 )
424
 	intelx_reset ( intel );
428
 	intelx_reset ( intel );
425
  err_reset:
429
  err_reset:
426
 	iounmap ( intel->regs );
430
 	iounmap ( intel->regs );
431
+ err_ioremap:
427
 	netdev_nullify ( netdev );
432
 	netdev_nullify ( netdev );
428
 	netdev_put ( netdev );
433
 	netdev_put ( netdev );
429
  err_alloc:
434
  err_alloc:

Loading…
Cancel
Save