- Aug 07, 2022
-
-
Julia Lawall authored
Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Julia Lawall authored
The various functions contain a NULL check starting in v5.15. Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Jul 16, 2022
-
-
Ziyang Xuan authored
Since commit b37a4668 ("netdevice: add the case if dev is NULL"), NULL check before dev_{put, hold} functions is not needed. Signed-off-by:
Ziyang Xuan <william.xuanziyang@huawei.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Steven Rostedt (Google) authored
There is nothing wrong with current code that returns 0 or 1 for a function returning bool. It is perfectly acceptable by the C standard. To avoid churn of unwanted patches that are constantly sent to maintainers who do not care about this change, remove the script that flags it as an issue. This issue is not worth the burden on maintainers to accept useless patches. Link: https://lore.kernel.org/all/20220705073822.7276-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/20220429075201.68581-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/1649236467-29390-1-git-send-email-baihaowen@meizu.com/ Link: https://lore.kernel.org/all/20220317014740.3138-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/190b5c2f2f2fb9cc775fce8daed72bf893be48a4.1642065293.git.davidcomponentone@gmail.com/ Link: https://lore.kernel.org/all/20211214113845.439392-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824065735.60660-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824064305.60081-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824062359.59474-1-deng.changcheng@zte.com.cn/ Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Julia Lawall <Julia.Lawall@lip6.fr> Cc: Michal Marek <mmarek@suse.cz> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by:
Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr> Acked-by:
Rasmus Villemoes <linux@rasmusvillemoes.dk> Acked-by:
Paul Gortmaker <paul.gortmaker@windriver.com>
-
- Jul 03, 2022
-
-
Jérémy LEFAURE authored
The test of an expression's address does not necessarily represent the whole condition, it may only be a part of it. Also, an expression's address is likely to be non-zero in every test expression, not only in if statements. This change aims at detecting an address test in more complex conditions and not only in if statements. Signed-off-by:
Jérémy Lefaure <jeremy.lefaure@netatmo.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Jan 15, 2022
-
-
Julia Lawall authored
This semantic patch does not take into account the fact that of_node_put can be safely applied to NULL. Thus it gives only false positives. Drop it. Reported-by:
Qing Wang <wangqing@vivo.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Julia Lawall authored
The BUG_ON script was never safe, in that it was not able to check whether the condition was side-effecting. At this point, BUG_ON should be well known, so it has probably outlived its usefuless. Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr> Suggested-by:
Matthew Wilcox <willy@infradead.org>
-
- Sep 11, 2021
-
-
Wen Yang authored
do_div() does a 64-by-32 division. When the divisor is unsigned long, u64, or s64, do_div() truncates it to 32 bits, this means it can test non-zero and be truncated to zero for division. This semantic patch is inspired by Mateusz Guzik's patch: commit b0ab99e7 ("sched: Fix possible divide by zero in avg_atom() calculation") Signed-off-by:
Wen Yang <wenyang@linux.alibaba.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr> Cc: Gilles Muller <Gilles.Muller@lip6.fr> Cc: Nicolas Palix <nicolas.palix@imag.fr> Cc: Michal Marek <michal.lkml@markovi.net> Cc: Matthias Maennich <maennich@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: cocci@systeme.lip6.fr Cc: linux-kernel@vger.kernel.org
-
- Aug 08, 2021
-
-
Daniel Thompson authored
Currently use_after_iter.cocci generates false positives for code of the following form: ~~~ list_for_each_entry(d, &ddata->irq_list, node) { if (irq == d->irq) break; } if (list_entry_is_head(d, &ddata->irq_list, node)) return IRQ_NONE; ~~~ [This specific example comes from drivers/power/supply/cpcap-battery.c] Most list macros use list_entry_is_head() as loop exit condition meaning it is not unsafe to reuse pos (a.k.a. d) in the code above. Let's avoid reporting these cases. Signed-off-by:
Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Aug 05, 2021
-
-
Weizhao Ouyang authored
Commit 453431a5 ("mm, treewide: rename kzfree() to kfree_sensitive()") renamed kzfree() to kfree_sensitive(), it should be applied to coccinelle. Signed-off-by:
Weizhao Ouyang <o451686892@gmail.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr> Acked-by:
Denis Efremov <efremov@linux.com>
-
- Jun 21, 2021
-
-
Keith Busch authored
Using kobj_to_dev() instead of container_of() is not universally accepted among maintainers as an improvement. The warning leads to repeated patch submissions that won't be accepted. Remove the script. Cc: Christoph Hellwig <hch@lst.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: Denis Efremov <efremov@linux.com> Cc: Julia Lawall <Julia.Lawall@inria.fr> Signed-off-by:
Keith Busch <kbusch@kernel.org> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr> Acked-by:
Jens Axboe <axboe@kernel.dk> Acked-by:
Denis Efremov <efremov@linux.com>
-
- May 01, 2021
-
-
Denis Efremov authored
There is a standard idiom for "if 'ret' holds an error, return it": return ret < 0 ? ret : 0; Developers prefer to keep the things as they are because stylistic change to "return min(ret, 0);" breaks readability. Let's suppress automatic generation for this type of patches. Signed-off-by:
Denis Efremov <efremov@linux.com>
-
Julia Lawall authored
Kfree.cocci only supports org and report mode, so the *s (used for context mode) are not useful. Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Krzysztof Kozlowski authored
The IRQF_ONESHOT should be present for threaded IRQ using default primary handler. However intetrupt of many child devices, e.g. children of MFD, is nested thus the IRQF_ONESHOT is not needed. The coccinelle message about error misleads submitters and reviewers about the severity of the issue, so make it a warning and mention possible false positive. Signed-off-by:
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Denis Efremov authored
Check for opencoded swap() implementation. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
Denis Efremov authored
Remove the documentation link from the warning message because commit 3942ea7a ("deprecated.rst: Remove now removed uninitialized_var") removed the section from documentation. Update the rule documentation accordingly. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
Denis Efremov authored
Skip patches generation for structs with a single field. Changing a zero-length array to a flexible array member in a struct with no named members breaks the compilation. However, reporting such cases is still valuable, e.g. commit 637464c5 ("ACPI: NFIT: Fix flexible_array.cocci warnings"). Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
Denis Efremov authored
Check for opencoded min(), max() implementations. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Feb 13, 2021
-
-
Rob Herring authored
of_dev_get() and of_dev_put are just wrappers for get_device()/put_device() on a platform_device. There's also already platform_device_{get,put}() wrappers for this purpose. Let's update the few users and remove of_dev_{get,put}(). Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Julia Lawall <Julia.Lawall@inria.fr> Cc: Gilles Muller <Gilles.Muller@inria.fr> Cc: Nicolas Palix <nicolas.palix@imag.fr> Cc: Michal Marek <michal.lkml@markovi.net> Cc: linuxppc-dev@lists.ozlabs.org Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-usb@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by:
Rob Herring <robh@kernel.org> Reviewed-by:
Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20210211232745.1498137-2-robh@kernel.org
-
- Dec 15, 2020
-
-
Maxime Ripard authored
The ptr_ret script script addresses a number of situations where we end up testing an error pointer, and if it's an error returning it, or return 0 otherwise to transform it into a PTR_ERR_OR_ZERO call. So it will convert a block like this: if (IS_ERR(err)) return PTR_ERR(err); return 0; into return PTR_ERR_OR_ZERO(err); While this is technically correct, it has a number of drawbacks. First, it merges the error and success path, which will make it harder for a reviewer or reader to grasp. It's also more difficult to extend if we were to add some code between the error check and the function return, making the author essentially revert that patch before adding new lines, while it would have been a trivial addition otherwise for the rewiever. Therefore, since that script is only about cosmetic in the first place, let's remove it since it's not worth it. Acked-by:
Jani Nikula <jani.nikula@intel.com> Acked-by:
Thierry Reding <treding@nvidia.com> Acked-by:
Julia Lawall <julia.lawall@inria.fr> Reviewed-by:
Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by:
Mark Brown <broonie@kernel.org> Signed-off-by:
Maxime Ripard <maxime@cerno.tech> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Nov 09, 2020
-
-
Peter Zijlstra authored
0/1 for booleans is perfectly valid C. Signed-off-by:
Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Oct 17, 2020
-
-
Denis Efremov authored
Check that alloc and free types of functions match each other. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@lip6.fr>
-
- Oct 15, 2020
-
-
Sumera Priyadarsini authored
While iterating over child nodes with the for_each functions, if control is transferred from the middle of the loop, as in the case of a break or return or goto, there is no decrement in the reference counter thus ultimately resulting in a memory leak. Add this script to detect potential memory leaks caused by the absence of of_node_put() before break, goto, or, return statements which transfer control outside the loop. Signed-off-by:
Sumera Priyadarsini <sylphrenadin@gmail.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Oct 10, 2020
-
-
Denis Efremov authored
Print memset() call position in addition to the kfree() position to ease issues identification. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Oct 03, 2020
-
-
Denis Efremov authored
One-element and zero-length arrays are deprecated [1]. Kernel code should always use "flexible array members" instead, except for existing uapi definitions. The script warns about one-element and zero-length arrays in structs. [1] commit 68e4cd17 ("docs: deprecated.rst: Add zero-length and one-element arrays") Cc: Kees Cook <keescook@chromium.org> Cc: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Oct 01, 2020
-
-
Denis Efremov authored
Suggest kvmalloc, kvfree instead of opencoded patterns. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <julia.lawall@inria.fr>
-
- Sep 21, 2020
-
-
Denis Efremov authored
Check for !A || A && B condition. It's equivalent to !A || B. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Sep 12, 2020
-
-
Denis Efremov authored
Commit 453431a5 ("mm, treewide: rename kzfree() to kfree_sensitive()") renames kzfree to kfree_sensitive and uses memzero_explicit(...) instead of memset(..., 0, ...) internally. Update cocci script to reflect these changes. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Sep 10, 2020
-
-
Mauro Carvalho Chehab authored
sysfs.txt was converted and renamed to sysfs.rst. Update device_attr_show.cocci script accordingly. Signed-off-by:
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/048ed24b09aefa0051d76396d6250e35e6ba035c.1599660067.git.mchehab+huawei@kernel.org Signed-off-by:
Jonathan Corbet <corbet@lwn.net>
-
- Sep 05, 2020
-
-
Denis Efremov authored
uninitialized_var() macro was removed from the sources [1] and other warning-silencing tricks were deprecated [2]. The purpose of this cocci script is to prevent new occurrences of uninitialized_var() open-coded variants. [1] commit 63a0895d ("compiler: Remove uninitialized_var() macro") [2] commit 4b19bec9 ("docs: deprecated.rst: Add uninitialized_var()") Cc: Kees Cook <keescook@chromium.org> Cc: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Sep 02, 2020
-
-
Denis Efremov authored
Extend the list of free functions with kvfree(), kvfree_sensitive(), vfree(). Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Aug 21, 2020
-
-
Denis Efremov authored
Use kobj_to_dev() instead of container_of(). Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Alex Dewar authored
Commit dfd32cad ("dma-mapping: remove dma_zalloc_coherent()") removed the definition of dma_zalloc_coherent() and also removed the corresponding patch rule for replacing instances of dma_alloc_coherent + memset in zalloc-simple.cocci (though left the report rule). Add a new patch rule to remove unnecessary calls to memset after allocating with dma_alloc_coherent. While we're at it, fix a couple of typos. Fixes: dfd32cad ("dma-mapping: remove dma_zalloc_coherent()") Signed-off-by:
Alex Dewar <alex.dewar90@gmail.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
- Aug 07, 2020
-
-
Waiman Long authored
As said by Linus: A symmetric naming is only helpful if it implies symmetries in use. Otherwise it's actively misleading. In "kzalloc()", the z is meaningful and an important part of what the caller wants. In "kzfree()", the z is actively detrimental, because maybe in the future we really _might_ want to use that "memfill(0xdeadbeef)" or something. The "zero" part of the interface isn't even _relevant_. The main reason that kzfree() exists is to clear sensitive information that should not be leaked to other future users of the same memory objects. Rename kzfree() to kfree_sensitive() to follow the example of the recently added kvfree_sensitive() and make the intention of the API more explicit. In addition, memzero_explicit() is used to clear the memory to make sure that it won't get optimized away by the compiler. The renaming is done by using the command sequence: git grep -w --name-only kzfree |\ xargs sed -i 's/kzfree/kfree_sensitive/' followed by some editing of the kfree_sensitive() kerneldoc and adding a kzfree backward compatibility macro in slab.h. [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h] [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more] Suggested-by:
Joe Perches <joe@perches.com> Signed-off-by:
Waiman Long <longman@redhat.com> Signed-off-by:
Andrew Morton <akpm@linux-foundation.org> Acked-by:
David Howells <dhowells@redhat.com> Acked-by:
Michal Hocko <mhocko@suse.com> Acked-by:
Johannes Weiner <hannes@cmpxchg.org> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Cc: James Morris <jmorris@namei.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: Joe Perches <joe@perches.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: David Rientjes <rientjes@google.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: "Jason A . Donenfeld" <Jason@zx2c4.com> Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com Signed-off-by:
Linus Torvalds <torvalds@linux-foundation.org>
-
- Aug 04, 2020
-
-
Denis Efremov authored
Don't match memdup_user/vmemdup_user. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Denis Efremov authored
Add vmemdup_user() transformations to the memdup_user.cocci rule. Commit 50fd2f29 ("new primitive: vmemdup_user()") introduced vmemdup_user(). The function uses kvmalloc with GPF_USER flag. Signed-off-by:
Denis Efremov <efremov@linux.com>
-
Denis Efremov authored
Match GFP_USER and optional __GFP_NOWARN allocations with memdup_user.cocci rule. Commit 6c2c97a2 ("memdup_user(): switch to GFP_USER") switched memdup_user() from GFP_KERNEL to GFP_USER. In almost all cases it is still a good idea to recommend memdup_user() for GFP_KERNEL allocations. The motivation behind altering memdup_user() to GFP_USER: https://lkml.org/lkml/2018/1/6/333 Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Denis Efremov authored
Check for memset()/memzero_explicit() followed by kfree()/vfree()/kvfree(). Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Denis Efremov authored
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-
Denis Efremov authored
There is a typo in rule r2. Position p1 should be attached to kzalloc() call. Fixes: 29a36d4d ("scripts/coccinelle: improve the coverage of some semantic patches") Signed-off-by:
Denis Efremov <efremov@linux.com> Signed-off-by:
Julia Lawall <Julia.Lawall@inria.fr>
-