lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57FC6B51.9030205@linux.intel.com>
Date:   Tue, 11 Oct 2016 12:32:17 +0800
From:   Lu Baolu <baolu.lu@...ux.intel.com>
To:     Baolin Wang <baolin.wang@...aro.org>
Cc:     Felipe Balbi <balbi@...nel.org>,
        Greg KH <gregkh@...uxfoundation.org>,
        Sebastian Reichel <sre@...nel.org>,
        Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
        David Woodhouse <dwmw2@...radead.org>, robh@...nel.org,
        Jun Li <jun.li@....com>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Ruslan Bilovol <ruslan.bilovol@...il.com>,
        Peter Chen <peter.chen@...escale.com>,
        Alan Stern <stern@...land.harvard.edu>, r.baldyga@...sung.com,
        grygorii.strashko@...com,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
        Lee Jones <lee.jones@...aro.org>,
        Mark Brown <broonie@...nel.org>,
        John Stultz <john.stultz@...aro.org>,
        Charles Keepax <ckeepax@...nsource.wolfsonmicro.com>,
        patches@...nsource.wolfsonmicro.com,
        Linux PM list <linux-pm@...r.kernel.org>,
        USB <linux-usb@...r.kernel.org>,
        device-mainlining@...ts.linuxfoundation.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget
 supporting for usb charger

Hi,

On 10/11/2016 12:07 PM, Baolin Wang wrote:
>>>  /*
>>> >> + * usb_charger_unregister() - Unregister a usb charger.
>>> >> + * @uchger - the usb charger to be unregistered.
>>> >> + */
>>> >> +static int usb_charger_unregister(struct usb_charger *uchger)
>>> >> +{
>>> >> +     ida_simple_remove(&usb_charger_ida, uchger->id);
>>> >> +     sysfs_remove_groups(&uchger->gadget->dev.kobj, usb_charger_groups);
>>> >> +
>>> >> +     mutex_lock(&charger_lock);
>>> >> +     list_del(&uchger->list);
>>> >> +     mutex_unlock(&charger_lock);
>>> >> +
>>> >> +     kfree(uchger);
>> >
>> > Any reasons you want to put kfree() here? You allocated the memory
>> > in usb_charger_init(). Isn't usb_charger_exit() a better place?
> The usb_charger_exit() will issue usb_charger_unregister() and we need
> use the usb_charger structure in usb_charger_unregister() to
> unregister the usb charger.
>

This seems not to be a strong reason. :-)

You can unregister the charger first and then free the structure.
Just do the reverse operation of what you have done in the init
function.

Best regards,
Lu Baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ