* [PATCH 0/2] delete null dereference @ 2015-10-17 9:32 ` Julia Lawall 0 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: netdev; +Cc: kernel-janitors, linux-wireless, linux-kernel, linux-media These patches delete NULL dereferences, as detected by scripts/coccinelle/null/deref_null.cocci. --- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 6 ++---- net/nfc/netlink.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/2] delete null dereference @ 2015-10-17 9:32 ` Julia Lawall 0 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: netdev; +Cc: kernel-janitors, linux-wireless, linux-kernel, linux-media These patches delete NULL dereferences, as detected by scripts/coccinelle/null/deref_null.cocci. --- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 6 ++---- net/nfc/netlink.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] NFC: delete null dereference 2015-10-17 9:32 ` Julia Lawall @ 2015-10-17 9:32 ` Julia Lawall -1 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: Lauro Ramos Venancio Cc: kernel-janitors, Aloisio Almeida Jr, Samuel Ortiz, David S. Miller, linux-wireless, netdev, linux-kernel The exit label performs device_unlock(&dev->dev);, which will fail when dev is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so just exit the function immediately. Problem found using scripts/coccinelle/null/deref_null.cocci Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> --- net/nfc/netlink.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 853172c..f040532 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1109,10 +1109,8 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); dev = nfc_get_device(idx); - if (!dev) { - rc = -ENODEV; - goto exit; - } + if (!dev) + return -ENODEV; device_lock(&dev->dev); ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 1/2] NFC: delete null dereference @ 2015-10-17 9:32 ` Julia Lawall 0 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: Lauro Ramos Venancio Cc: kernel-janitors, Aloisio Almeida Jr, Samuel Ortiz, David S. Miller, linux-wireless, netdev, linux-kernel The exit label performs device_unlock(&dev->dev);, which will fail when dev is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so just exit the function immediately. Problem found using scripts/coccinelle/null/deref_null.cocci Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> --- net/nfc/netlink.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 853172c..f040532 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1109,10 +1109,8 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); dev = nfc_get_device(idx); - if (!dev) { - rc = -ENODEV; - goto exit; - } + if (!dev) + return -ENODEV; device_lock(&dev->dev); ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] NFC: delete null dereference 2015-10-17 9:32 ` Julia Lawall @ 2015-10-19 12:57 ` Dan Carpenter -1 siblings, 0 replies; 10+ messages in thread From: Dan Carpenter @ 2015-10-19 12:57 UTC (permalink / raw) To: Julia Lawall Cc: Lauro Ramos Venancio, kernel-janitors, Aloisio Almeida Jr, Samuel Ortiz, David S. Miller, linux-wireless, netdev, linux-kernel The next goto after that is messed up as well: 1056 dev = nfc_get_device(idx); 1057 if (!dev) 1058 return -ENODEV; 1059 1060 device_lock(&dev->dev); 1061 1062 local = nfc_llcp_find_local(dev); 1063 if (!local) { 1064 nfc_put_device(dev); It should not call nfc_put_device() because that happens after goto exit. 1065 rc = -ENODEV; 1066 goto exit; 1067 } regards, dan carpenter ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] NFC: delete null dereference @ 2015-10-19 12:57 ` Dan Carpenter 0 siblings, 0 replies; 10+ messages in thread From: Dan Carpenter @ 2015-10-19 12:57 UTC (permalink / raw) To: Julia Lawall Cc: Lauro Ramos Venancio, kernel-janitors, Aloisio Almeida Jr, Samuel Ortiz, David S. Miller, linux-wireless, netdev, linux-kernel The next goto after that is messed up as well: 1056 dev = nfc_get_device(idx); 1057 if (!dev) 1058 return -ENODEV; 1059 1060 device_lock(&dev->dev); 1061 1062 local = nfc_llcp_find_local(dev); 1063 if (!local) { 1064 nfc_put_device(dev); It should not call nfc_put_device() because that happens after goto exit. 1065 rc = -ENODEV; 1066 goto exit; 1067 } regards, dan carpenter ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] NFC: delete null dereference 2015-10-17 9:32 ` Julia Lawall @ 2015-10-20 4:50 ` Samuel Ortiz -1 siblings, 0 replies; 10+ messages in thread From: Samuel Ortiz @ 2015-10-20 4:50 UTC (permalink / raw) To: Julia Lawall Cc: Lauro Ramos Venancio, kernel-janitors, Aloisio Almeida Jr, David S. Miller, linux-wireless, netdev, linux-kernel Hi Julia, On Sat, Oct 17, 2015 at 11:32:19AM +0200, Julia Lawall wrote: > The exit label performs device_unlock(&dev->dev);, which will fail when dev > is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so > just exit the function immediately. > > Problem found using scripts/coccinelle/null/deref_null.cocci > > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> > > --- > net/nfc/netlink.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) Applied to nfc-next, thanks. Cheers, Samuel. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] NFC: delete null dereference @ 2015-10-20 4:50 ` Samuel Ortiz 0 siblings, 0 replies; 10+ messages in thread From: Samuel Ortiz @ 2015-10-20 4:50 UTC (permalink / raw) To: Julia Lawall Cc: Lauro Ramos Venancio, kernel-janitors, Aloisio Almeida Jr, David S. Miller, linux-wireless, netdev, linux-kernel Hi Julia, On Sat, Oct 17, 2015 at 11:32:19AM +0200, Julia Lawall wrote: > The exit label performs device_unlock(&dev->dev);, which will fail when dev > is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so > just exit the function immediately. > > Problem found using scripts/coccinelle/null/deref_null.cocci > > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> > > --- > net/nfc/netlink.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) Applied to nfc-next, thanks. Cheers, Samuel. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] [media] netup_unidvb: delete null dereference 2015-10-17 9:32 ` Julia Lawall @ 2015-10-17 9:32 ` Julia Lawall -1 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: Sergey Kozlov Cc: kernel-janitors, Mauro Carvalho Chehab, linux-media, linux-kernel The calls to dev_dbg will not work properly when spi is NULL. Just use pr_debug instead. Problem found using scripts/coccinelle/null/deref_null.cocci Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> --- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c index f55b327..026895f 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c @@ -81,8 +81,7 @@ irqreturn_t netup_spi_interrupt(struct netup_spi *spi) unsigned long flags; if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + pr_debug("%s(): SPI not initialized\n", __func__); return IRQ_NONE; } spin_lock_irqsave(&spi->lock, flags); @@ -235,8 +234,7 @@ void netup_spi_release(struct netup_unidvb_dev *ndev) struct netup_spi *spi = ndev->spi; if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + pr_debug("%s(): SPI not initialized\n", __func__); return; } spin_lock_irqsave(&spi->lock, flags); ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] [media] netup_unidvb: delete null dereference @ 2015-10-17 9:32 ` Julia Lawall 0 siblings, 0 replies; 10+ messages in thread From: Julia Lawall @ 2015-10-17 9:32 UTC (permalink / raw) To: Sergey Kozlov Cc: kernel-janitors, Mauro Carvalho Chehab, linux-media, linux-kernel The calls to dev_dbg will not work properly when spi is NULL. Just use pr_debug instead. Problem found using scripts/coccinelle/null/deref_null.cocci Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> --- drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c index f55b327..026895f 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c @@ -81,8 +81,7 @@ irqreturn_t netup_spi_interrupt(struct netup_spi *spi) unsigned long flags; if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + pr_debug("%s(): SPI not initialized\n", __func__); return IRQ_NONE; } spin_lock_irqsave(&spi->lock, flags); @@ -235,8 +234,7 @@ void netup_spi_release(struct netup_unidvb_dev *ndev) struct netup_spi *spi = ndev->spi; if (!spi) { - dev_dbg(&spi->master->dev, - "%s(): SPI not initialized\n", __func__); + pr_debug("%s(): SPI not initialized\n", __func__); return; } spin_lock_irqsave(&spi->lock, flags); ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-10-20 4:51 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-17 9:32 [PATCH 0/2] delete null dereference Julia Lawall 2015-10-17 9:32 ` Julia Lawall 2015-10-17 9:32 ` [PATCH 1/2] NFC: " Julia Lawall 2015-10-17 9:32 ` Julia Lawall 2015-10-19 12:57 ` Dan Carpenter 2015-10-19 12:57 ` Dan Carpenter 2015-10-20 4:50 ` Samuel Ortiz 2015-10-20 4:50 ` Samuel Ortiz 2015-10-17 9:32 ` [PATCH 2/2] [media] netup_unidvb: " Julia Lawall 2015-10-17 9:32 ` Julia Lawall
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.