patch: new patch pattern iounmap_missing.cocci

add missing iounmap() on error in {{function}}

Add the missing iounmap() before return from {{function}}
in the error handling case.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: new patch pattern kmem_cache_free.cocci

use kmem_cache_free() instead of kfree()

memory allocated by kmem_cache_alloc() should be freed using
kmem_cache_free(), not kfree().

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: new patch pattern platform_driver_unregister_unbalance.cocci

add missing platform_driver_unregister() when module exit

We have registered platform driver when module init, and
need unregister it when module exit.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: new patch pattern input_free_device_chk.cocci

don't call input_free_device() after input_unregister_device()

input_free_device() should only be used if input_register_device()
was not called yet or if it failed. Once device was unregistered
use input_unregister_device() and memory will be freed once last
reference to the device is dropped.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
report: new report pattern ret_err.cocci

fix error return code in {{function}}

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
report: new report pattern krealloc_leak.cocci

fix krealloc() misuse in in {{function}}

If krealloc() returns NULL, it doesn't free the original. So any code
of the form 'foo = krealloc(foo, ...);' is almost certainly a bug.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: update some patch patterns

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: new patch pattern usb_free_urb.cocci

remove needless check before usb_free_urb()

usb_free_urb(NULL) is safe and this check is not required.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
patch: new patch pattern usb_free_coherent.cocci

remove needless check before usb_free_coherent()

usb_free_coherent() is safe with NULL addr and this check is
not required.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
report: new report pattern kfree_leak.cocci

fix possible memory leak in {{function}}

memory is malloced in {{function}} and should be freed before
leaving from the error handling cases, otherwise it will cause
memory leak.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>