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: <20220221130548.GK3965@kadam>
Date:   Mon, 21 Feb 2022 16:05:48 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Tong Zhang <ztong0001@...il.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Lee Jones <lee.jones@...aro.org>,
        Colin Ian King <colin.i.king@...glemail.com>,
        Saurav Girepunje <saurav.girepunje@...il.com>,
        Johan Hovold <johan@...nel.org>,
        Cláudio Maia <clrrm@...p.ipp.pt>,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: rtl8192u: cleanup proc fs entries upon exit

On Mon, Feb 21, 2022 at 04:00:06PM +0300, Dan Carpenter wrote:
> On Sun, Feb 20, 2022 at 03:15:53PM -0800, Tong Zhang wrote:
> > proc fs entries need to be removed when module is removed, otherwise
> > when we try to insert the module again, kernel will complain
> > 
> > [  493.068012] proc_dir_entry 'net/ieee80211' already registered
> > [  493.271973]  proc_mkdir+0x18/0x20
> > [  493.272136]  ieee80211_debug_init+0x28/0xde8 [r8192u_usb]
> > [  493.272404]  rtl8192_usb_module_init+0x10/0x161 [r8192u_usb]
> > 
> > [   13.910616] proc_dir_entry 'net/rtl819xU' already registered
> > [   13.918931]  proc_mkdir+0x18/0x20
> > [   13.919098]  rtl8192_usb_module_init+0x142/0x16d [r8192u_usb]
> > 
> > Signed-off-by: Tong Zhang <ztong0001@...il.com>
> > ---
> 
> This is a partial fix but there is a lot wrong with both the init() and
> exit() function.  It's not hard to just fix everything and it saves
> time.
> 
> Here is how to write Free the Last thing style error handling for init()
> and when you finish writing the error handling code then the exit()
> function is just a matter of cut and paste.
> 
> The rules are: 1) Free the last successful allocation.  2) Every
> function must have a matching release function. 3) Every function must
> clean up after itself.  No partial allocations.  4) Name your labels
> with descriptive names to say what the goto does.

I meant to add:

5)  Free things in reverse order from how they were allocated.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ