Re: [PATCH] gpio: gpiolib: fix refcount imbalance in gpiochip_setup_dev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Most static checker stuff is cleanup code.  I've written a blog entry on
clean up code.

https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/

You mostly get this right, but one thing which could help is rule #6
where ideally the cleanup in the function is copy and pasted to create
the release function.

So when you add cleanup to the error paths, check the release function
and see what it does.  Sometimes you've seen the clean up code is missing
in the release function.  Other times it calls wrapper like
gpio_put_device() instead of calling put_device() directly.  The function
calls should be in a specific order, (hopefully the reverse order of how
they're allocated).

regards,
dan carpenter





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux