Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1628967 > unrolled thread
| Started by | Pan Bian <bianpan201602@163.com> |
|---|---|
| First post | 2017-04-23 12:00 +0200 |
| Last post | 2017-04-24 11:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value Pan Bian <bianpan201602@163.com> - 2017-04-23 12:00 +0200
Re: [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value Ian Abbott <abbotti@mev.co.uk> - 2017-04-24 11:30 +0200
| From | Pan Bian <bianpan201602@163.com> |
|---|---|
| Date | 2017-04-23 12:00 +0200 |
| Subject | [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value |
| Message-ID | <tzmtb-6QE-1@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Ian Abbott <abbotti@mev.co.uk> |
|---|---|
| Date | 2017-04-24 11:30 +0200 |
| Message-ID | <tzItI-5cz-11@gated-at.bofh.it> |
| In reply to | #1628967 |
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/ )=-
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web