* [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value
@ 2017-04-23 9:52 Pan Bian
2017-04-24 9:28 ` Ian Abbott
0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2017-04-23 9:52 UTC (permalink / raw)
To: Ian Abbott, H Hartley Sweeten, Greg Kroah-Hartman
Cc: devel, linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
Function pci_ioremap_bar() will return a NULL pointer if there is no
enough memory. However, in function apci3xxx_auto_attach(), the return
value of function pci_ioremap_bar() is not validated. This may result in
NULL dereference in following access to dev->mmio. This patch fixes the
bug.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
index b6af3eb..a07d5bd 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
@@ -787,6 +787,8 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
dev->iobase = pci_resource_start(pcidev, 2);
dev->mmio = pci_ioremap_bar(pcidev, 3);
+ if (!dev->mmio)
+ return -ENOMEM;
if (pcidev->irq > 0) {
ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value
2017-04-23 9:52 [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value Pan Bian
@ 2017-04-24 9:28 ` Ian Abbott
0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2017-04-24 9:28 UTC (permalink / raw)
To: Pan Bian, H Hartley Sweeten, Greg Kroah-Hartman
Cc: devel, linux-kernel, Pan Bian
On 23/04/17 10:52, Pan Bian wrote:
> From: Pan Bian <bianpan2016@163.com>
>
> Function pci_ioremap_bar() will return a NULL pointer if there is no
> enough memory. However, in function apci3xxx_auto_attach(), the return
> value of function pci_ioremap_bar() is not validated. This may result in
> NULL dereference in following access to dev->mmio. This patch fixes the
> bug.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> index b6af3eb..a07d5bd 100644
> --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> @@ -787,6 +787,8 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
>
> dev->iobase = pci_resource_start(pcidev, 2);
> dev->mmio = pci_ioremap_bar(pcidev, 3);
> + if (!dev->mmio)
> + return -ENOMEM;
>
> if (pcidev->irq > 0) {
> ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
>
Looks good. Thanks for the fix.
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-24 9:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 9:52 [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value Pan Bian
2017-04-24 9:28 ` Ian Abbott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®