* [PATCH] hci_bcm.c: fix missing return value check of devm_clk_get()
@ 2018-08-18 2:06 Jiecheng Wu
2018-08-21 14:38 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Jiecheng Wu @ 2018-08-18 2:06 UTC (permalink / raw)
To: linux-bluetooth
Function bcm_get_resources() defined in drivers/bluetooth/hci_bcm.c calls devm_clk_get() that may return an error code. The return value of function bcm_get_resources() should be checked whether it is an error code.
---
drivers/bluetooth/hci_bcm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index ddbd8c6..f4089a2 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -906,6 +906,8 @@ static int bcm_get_resources(struct bcm_device *dev)
return 0;
dev->clk = devm_clk_get(dev->dev, NULL);
+ if (IS_ERR(dev->clk))
+ return PTR_ERR(dev->clk);
dev->device_wakeup = devm_gpiod_get_optional(dev->dev, "device-wakeup",
GPIOD_OUT_LOW);
--
2.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hci_bcm.c: fix missing return value check of devm_clk_get()
2018-08-18 2:06 [PATCH] hci_bcm.c: fix missing return value check of devm_clk_get() Jiecheng Wu
@ 2018-08-21 14:38 ` Marcel Holtmann
2018-08-21 14:49 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2018-08-21 14:38 UTC (permalink / raw)
To: Jiecheng Wu, Hans de Goede; +Cc: linux-bluetooth
Hi Jiecheng,
> Function bcm_get_resources() defined in drivers/bluetooth/hci_bcm.c calls devm_clk_get() that may return an error code. The return value of function bcm_get_resources() should be checked whether it is an error code.
> ---
> drivers/bluetooth/hci_bcm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index ddbd8c6..f4089a2 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -906,6 +906,8 @@ static int bcm_get_resources(struct bcm_device *dev)
> return 0;
>
> dev->clk = devm_clk_get(dev->dev, NULL);
> + if (IS_ERR(dev->clk))
> + return PTR_ERR(dev->clk);
is this really needed? I assume it all fails gracefully.
Regards
Marcel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hci_bcm.c: fix missing return value check of devm_clk_get()
2018-08-21 14:38 ` Marcel Holtmann
@ 2018-08-21 14:49 ` Hans de Goede
0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2018-08-21 14:49 UTC (permalink / raw)
To: Marcel Holtmann, Jiecheng Wu; +Cc: linux-bluetooth
Hi,
On 21-08-18 16:38, Marcel Holtmann wrote:
> Hi Jiecheng,
>
>> Function bcm_get_resources() defined in drivers/bluetooth/hci_bcm.c calls devm_clk_get() that may return an error code. The return value of function bcm_get_resources() should be checked whether it is an error code.
>> ---
>> drivers/bluetooth/hci_bcm.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> index ddbd8c6..f4089a2 100644
>> --- a/drivers/bluetooth/hci_bcm.c
>> +++ b/drivers/bluetooth/hci_bcm.c
>> @@ -906,6 +906,8 @@ static int bcm_get_resources(struct bcm_device *dev)
>> return 0;
>>
>> dev->clk = devm_clk_get(dev->dev, NULL);
>> + if (IS_ERR(dev->clk))
>> + return PTR_ERR(dev->clk);
>
> is this really needed? I assume it all fails gracefully.
This is not necessary, this will actually break things on x86 since
we don't have a clk to get there, all future references
to dev->clk are protected like this:
if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled) {
Notice the !IS_ERR(dev->clk), this is there exactly because
hci_bcm.c's use of the clk is optional, and this patch would break
that, so NACK.
Regards,
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-21 14:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-18 2:06 [PATCH] hci_bcm.c: fix missing return value check of devm_clk_get() Jiecheng Wu
2018-08-21 14:38 ` Marcel Holtmann
2018-08-21 14:49 ` Hans de Goede
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).