From: Alan Jenkins <sourcejedi.lkml@googlemail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Mario Limonciello <mario_limonciello@dell.com>,
cezary.jackiewicz@gmail.com, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] Add rfkill support to compal-laptop
Date: Tue, 18 Aug 2009 15:52:18 +0100 [thread overview]
Message-ID: <9b2b86520908180752k66feda09rf9034a96ac6ef470@mail.gmail.com> (raw)
In-Reply-To: <9b2b86520908180044l72cb8642j6256e246662f7971@mail.gmail.com>
On 8/18/09, Alan Jenkins <sourcejedi.lkml@googlemail.com> wrote:
> On 8/18/09, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Mario,
>
> ...
>
>>> +static int setup_rfkill(void)
>>> +{
>>> + int ret;
>>> +
>>> + wifi_rfkill = rfkill_alloc("compal-wifi", NULL,
>>> RFKILL_TYPE_WLAN,
>>> + &compal_rfkill_ops, (void *)
>>> WLAN_MASK);
>>> + if (!wifi_rfkill) {
>>> + ret = -ENOMEM;
>>> + goto err_wifi;
>>> + }
>>> + ret = rfkill_register(wifi_rfkill);
>>> + if (ret)
>>> + goto err_wifi;
>>> +
>>> + bluetooth_rfkill = rfkill_alloc("compal-bluetooth", NULL,
>>> RFKILL_TYPE_BLUETOOTH,
>>> + &compal_rfkill_ops, (void *)
>>> BT_MASK);
>>> + if (!bluetooth_rfkill) {
>>> + ret = -ENOMEM;
>>> + goto err_bt;
>>> + }
>>> + ret = rfkill_register(bluetooth_rfkill);
>>> + if (ret)
>>> + goto err_bt;
>>> +
>>> + return 0;
>>> +err_bt:
>>> + rfkill_destroy(bluetooth_rfkill);
>>> + if (bluetooth_rfkill)
>>> + rfkill_unregister(bluetooth_rfkill);
>>> +err_wifi:
>>> + rfkill_destroy(wifi_rfkill);
>>> + if (wifi_rfkill)
>>> + rfkill_unregister(wifi_rfkill);
>>
>> I don't understand how this is not a potential NULL pointer dereference.
>> There might some good luck that the pointer is still valid at that time,
>> but I highly doubt it. So please unregister before destory.
>
> Wrong as well :-).
>
> If you fail to register wifi_rfkill, you should *only* call
> rfkill_destroy(). So I think it should look like this:
>
> + if (wifi_rfkill)
> + rfkill_unregister(wifi_rfkill);
> +err_wifi:
> + rfkill_destroy(wifi_rfkill);
>
> ...
>
>>> @@ -420,6 +518,10 @@
>>> platform_device_unregister(compal_device);
>>> platform_driver_unregister(&compal_driver);
>>> backlight_device_unregister(compalbl_device);
>>> + if (wifi_rfkill)
>>> + rfkill_unregister(wifi_rfkill);
>>> + if (bluetooth_rfkill)
>>> + rfkill_unregister(bluetooth_rfkill);
>>
>> Same here. It should never ever succeeded in the first place. You can
>> call it conditionally.
>
> They're already called conditionally. I assume you mean unconditionally
> here.
Also, you're missing the calls to rfkill_destroy() here.
Whew, I think that's everything. I hope you find the feedback useful,
despite it being a little fragmented.
Regards
Alan
next prev parent reply other threads:[~2009-08-18 14:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-17 23:27 Mario Limonciello
2009-08-18 1:24 ` Marcel Holtmann
2009-08-18 7:44 ` Alan Jenkins
2009-08-18 14:52 ` Alan Jenkins [this message]
2009-08-18 17:26 ` Mario Limonciello
2009-08-18 21:08 ` Alan Jenkins
2009-08-18 21:31 ` Johannes Berg
2009-08-18 22:00 ` Mario Limonciello
2009-08-19 8:51 ` Alan Jenkins
2009-08-19 9:01 ` Johannes Berg
2009-08-19 11:43 ` Cezary Jackiewicz
2009-08-19 16:46 ` Mario Limonciello
2009-08-19 16:57 ` Alan Jenkins
2009-08-19 17:13 ` Johannes Berg
2009-08-19 18:39 ` Mario Limonciello
2009-08-18 21:17 ` Alan Jenkins
2009-08-18 8:33 ` Alan Jenkins
2009-08-18 8:19 ` Alan Jenkins
2009-08-18 12:22 ` Alan Jenkins
2009-08-19 18:36 Mario Limonciello
2009-08-19 18:42 ` Johannes Berg
2009-08-19 18:47 ` Mario Limonciello
2009-08-20 8:52 ` Alan Jenkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b2b86520908180752k66feda09rf9034a96ac6ef470@mail.gmail.com \
--to=sourcejedi.lkml@googlemail.com \
--cc=cezary.jackiewicz@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=mario_limonciello@dell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®