* [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl
@ 2012-05-31 20:39 Hauke Mehrtens
2012-06-01 8:12 ` Arend van Spriel
0 siblings, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2012-05-31 20:39 UTC (permalink / raw)
To: linville; +Cc: zajec5, b43-dev, linux-wireless, Hauke Mehrtens
pc could be null if hosttype != BCMA_HOSTTYPE_PCI.
If we are on a device without a pci core this function is called with
pc = null by b43 and brcmsmac. If the host type is PCI we have a pci
core as well and pc can not be null.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/bcma/driver_pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 9a96f14..884b7af 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -232,7 +232,7 @@ void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
bool enable)
{
- struct pci_dev *pdev = pc->core->bus->host_pci;
+ struct pci_dev *pdev;
u32 coremask, tmp;
int err = 0;
@@ -243,6 +243,8 @@ int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
goto out;
}
+ pdev = pc->core->bus->host_pci;
+
err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
if (err)
goto out;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl
2012-05-31 20:39 [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl Hauke Mehrtens
@ 2012-06-01 8:12 ` Arend van Spriel
2012-06-01 20:33 ` Hauke Mehrtens
0 siblings, 1 reply; 4+ messages in thread
From: Arend van Spriel @ 2012-06-01 8:12 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: linville, zajec5, b43-dev, linux-wireless
On 05/31/2012 10:39 PM, Hauke Mehrtens wrote:
> pc could be null if hosttype != BCMA_HOSTTYPE_PCI.
> If we are on a device without a pci core this function is called with
> pc = null by b43 and brcmsmac. If the host type is PCI we have a pci
> core as well and pc can not be null.
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
> drivers/bcma/driver_pci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
> index 9a96f14..884b7af 100644
> --- a/drivers/bcma/driver_pci.c
> +++ b/drivers/bcma/driver_pci.c
> @@ -232,7 +232,7 @@ void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
> int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
> bool enable)
> {
> - struct pci_dev *pdev = pc->core->bus->host_pci;
> + struct pci_dev *pdev;
> u32 coremask, tmp;
> int err = 0;
>
> @@ -243,6 +243,8 @@ int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
Could you change the if statement as well:
- if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
+ if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI)
> goto out;
- }
>
> + pdev = pc->core->bus->host_pci;
> +
> err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
> if (err)
> goto out;
Gr. AvS
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl
2012-06-01 8:12 ` Arend van Spriel
@ 2012-06-01 20:33 ` Hauke Mehrtens
2012-06-01 22:56 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2012-06-01 20:33 UTC (permalink / raw)
To: Arend van Spriel; +Cc: linville, zajec5, b43-dev, linux-wireless, Joe Perches
On 06/01/2012 10:12 AM, Arend van Spriel wrote:
> On 05/31/2012 10:39 PM, Hauke Mehrtens wrote:
>> pc could be null if hosttype != BCMA_HOSTTYPE_PCI.
>> If we are on a device without a pci core this function is called with
>> pc = null by b43 and brcmsmac. If the host type is PCI we have a pci
>> core as well and pc can not be null.
>>
>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
>> ---
>> drivers/bcma/driver_pci.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
>> index 9a96f14..884b7af 100644
>> --- a/drivers/bcma/driver_pci.c
>> +++ b/drivers/bcma/driver_pci.c
>> @@ -232,7 +232,7 @@ void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
>> int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
>> bool enable)
>> {
>> - struct pci_dev *pdev = pc->core->bus->host_pci;
>> + struct pci_dev *pdev;
>> u32 coremask, tmp;
>> int err = 0;
>>
>> @@ -243,6 +243,8 @@ int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
> Could you change the if statement as well:
> - if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
> + if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI)
Yes that's good I will change that, just to be save.
>> /* This bcma device is not on a PCI host-bus. So the IRQs are
>> * not routed through the PCI core.
>> * So we must not enable routing through the PCI core. */
>> goto out;
> - }
Is removing the braces correct here? There is just one line of code so
it will compile and the braces are not necessary, but I think it would
looks somehow strange because there is a 3 line comment in addition to
the one line of code in that if block.
@Joe Perches what do you think about this?
>> + pdev = pc->core->bus->host_pci;
>> +
>> err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
>> if (err)
>> goto out;
Hauke
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl
2012-06-01 20:33 ` Hauke Mehrtens
@ 2012-06-01 22:56 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2012-06-01 22:56 UTC (permalink / raw)
To: Hauke Mehrtens
Cc: Arend van Spriel, linville, zajec5, b43-dev, linux-wireless
On Fri, 2012-06-01 at 22:33 +0200, Hauke Mehrtens wrote:
> On 06/01/2012 10:12 AM, Arend van Spriel wrote:
> > On 05/31/2012 10:39 PM, Hauke Mehrtens wrote:
> >> pc could be null if hosttype != BCMA_HOSTTYPE_PCI.
> >> If we are on a device without a pci core this function is called with
> >> pc = null by b43 and brcmsmac. If the host type is PCI we have a pci
> >> core as well and pc can not be null.
> >>
> >> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> >> ---
> >> drivers/bcma/driver_pci.c | 4 +++-
> >> 1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
> >> index 9a96f14..884b7af 100644
> >> --- a/drivers/bcma/driver_pci.c
> >> +++ b/drivers/bcma/driver_pci.c
> >> @@ -232,7 +232,7 @@ void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
> >> int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
> >> bool enable)
> >> {
> >> - struct pci_dev *pdev = pc->core->bus->host_pci;
> >> + struct pci_dev *pdev;
> >> u32 coremask, tmp;
> >> int err = 0;
> >>
> >> @@ -243,6 +243,8 @@ int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
> > Could you change the if statement as well:
> > - if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
> > + if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI)
>
> Yes that's good I will change that, just to be save.
>
> >> /* This bcma device is not on a PCI host-bus. So the IRQs are
> >> * not routed through the PCI core.
> >> * So we must not enable routing through the PCI core. */
> >> goto out;
> > - }
>
> Is removing the braces correct here? There is just one line of code so
> it will compile and the braces are not necessary, but I think it would
> looks somehow strange because there is a 3 line comment in addition to
> the one line of code in that if block.
>
> @Joe Perches what do you think about this?
I try not to tell others what they must do, I just
try to suggest more standard ways to do things.
I think it's better to use braces when there's a
multiline comment after a test with a single statement.
if (some_test()) {
/* a multiline
* comment
*/
single_statement(action);
}
But I would tend to move that sort of comment above the fold
and use something like:
/* If the bcma device is not on a PCI host-bus,
* IRQs are not routed through the PCI core.
*/
if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI)
goto out;
Feel free to do what you you think best.
cheers, Joe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-01 22:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31 20:39 [PATCH] bcma: fix null pointer in bcma_core_pci_irq_ctl Hauke Mehrtens
2012-06-01 8:12 ` Arend van Spriel
2012-06-01 20:33 ` Hauke Mehrtens
2012-06-01 22:56 ` Joe Perches
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).