From: Markus Elfring <Markus.Elfring@web.de>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Felipe Balbi <felipe.balbi@linux.intel.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Coccinelle <cocci@systeme.lip6.fr>
Cc: Colin Ian King <colin.king@canonical.com>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Searching for initialisation of variables by function calls before null pointer checks
Date: Mon, 29 Jun 2020 18:19:41 +0200 [thread overview]
Message-ID: <5b693ee0-0cb1-7ff3-b562-bac6bcb6aae8@web.de> (raw)
In-Reply-To: <1593410434-19406-2-git-send-email-chunfeng.yun@mediatek.com>
> Some pointers are dereferenced before successful checks.
A source code place can be pointed out in an acceptable time frame for
a single file by the following script variant for the semantic patch language.
@display@
expression action1, action2;
expression* pointer1, pointer2;
identifier result1, result2;
statement is, es;
type t1, t2;
@@
t1 result1 = <+...
* action1(..., pointer1, ...)
...+>;
... when any
when != pointer1
t2 result2 = <+...
* action2(..., pointer2, ...)
...+>;
... when any
when != pointer1
when != pointer2
*if (!pointer1 || !pointer2 || ...)
is
else
es
elfring@Sonne:~/Projekte/Linux/next-patched> time spatch --profile --no-loops drivers/usb/mtu3/mtu3_gadget.c ~/Projekte/Coccinelle/janitor/show_pointer_usage_before_null_check11.cocci
…
@@ -332,14 +332,11 @@ error:
static int mtu3_gadget_dequeue(struct usb_ep *ep, struct usb_request *req)
{
- struct mtu3_ep *mep = to_mtu3_ep(ep);
- struct mtu3_request *mreq = to_mtu3_request(req);
struct mtu3_request *r;
unsigned long flags;
int ret = 0;
struct mtu3 *mtu = mep->mtu;
- if (!ep || !req || mreq->mep != mep)
return -EINVAL;
dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req);
---------------------
profiling result
---------------------
Main total : 2.030205 sec 1 count
Main.outfiles computation : 1.648542 sec 1 count
…
real 0m2,122s
user 0m1,977s
sys 0m0,037s
I have tried this analysis approach out also for source files from
the software “Linux next-20200626”.
elfring@Sonne:~/Projekte/Linux/next-patched> XX=$(date) && spatch --no-loops --timeout 12 -j 4 --chunksize 1 -dir ~/Projekte/Linux/next-patched ~/Projekte/Coccinelle/janitor/show_pointer_usage_before_null_check11.cocci > ~/Projekte/Bau/Linux/scripts/Coccinelle/null/next/20200626/show_pointer_usage_before_null_check11.diff 2> ~/Projekte/Bau/Linux/scripts/Coccinelle/null/next/20200626/show_pointer_usage_before_null_check11-errors.txt; YY=$(date) && echo "$XX | $YY"
Mo 29. Jun 13:54:54 CEST 2020 | Mo 29. Jun 17:22:37 CEST 2020
Unfortunately, a lot of “exceptional” data processing results were logged then.
elfring@Sonne:~/Projekte/Bau/Linux/scripts/Coccinelle/null/next/20200626> grep 'EXN: Coccinelle_modules.Common.Timeout' show_pointer_usage_before_null_check11-errors.txt | wc -l
454
Will such a test run trigger any further development considerations?
Regards,
Markus
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2020-06-29 16:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 6:00 [PATCH 1/2] usb: mtu3: disable USB2 LPM Chunfeng Yun
2020-06-29 6:00 ` [PATCH 2/2] usb: mtu3: fix NULL pointer dereference Chunfeng Yun
2020-06-29 8:00 ` Markus Elfring
2020-06-29 8:10 ` Greg Kroah-Hartman
2020-06-30 7:28 ` Chunfeng Yun
2020-06-29 16:19 ` Markus Elfring [this message]
2020-06-29 7:30 ` [PATCH 1/2] usb: mtu3: disable USB2 LPM Markus Elfring
2020-06-29 8:10 ` Greg Kroah-Hartman
2020-06-29 7:37 ` Peter Chen
2020-06-30 7:03 ` Chunfeng Yun
2020-06-29 8:15 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b693ee0-0cb1-7ff3-b562-bac6bcb6aae8@web.de \
--to=markus.elfring@web.de \
--cc=chunfeng.yun@mediatek.com \
--cc=cocci@systeme.lip6.fr \
--cc=colin.king@canonical.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).