linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "weiyongjun (A)" <weiyongjun1@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	<linux-media@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] media: v4l2-subdev: fix some NULL vs IS_ERR() checks
Date: Wed, 23 Jun 2021 10:29:43 +0800	[thread overview]
Message-ID: <623db5b4-77e6-9fbf-37b4-6d6e2925ad84@huawei.com> (raw)
In-Reply-To: <20210622155858.GN1861@kadam>


在 2021/6/22 23:58, Dan Carpenter 写道:
> On Tue, Jun 22, 2021 at 06:08:30PM +0300, Laurent Pinchart wrote:
>> Hi Dan,
>>
>> Thank you for the patch.
>>
>> On Tue, Jun 22, 2021 at 05:31:53PM +0300, Dan Carpenter wrote:
>>> The v4l2_subdev_alloc_state() function returns error pointers, it
>>> doesn't return NULL.
>> It's funny you send this patch today, I've been thinking about the exact
>> same issue yesterday, albeit more globally, when trying to figure out if
>> a function I called returned NULL or an error pointer on error.
>>
>> Would it make to create an __err_ptr annotation to mark functions that
>> return an error pointer ? This would both give a simple indication to
>> the user and allow tools such as smatch to detect errors.
>>
> If you have the cross function DB enabled then Smatch can figure out if
> it returns error pointers or NULL.  The big problem is that Smatch works
> on the precompiled code and doesn't understand ifdeffed code.
>
> I haven't pushed all the Smatch checks.  I told someone last month, I'd
> give them a month to fix any bugs since it was their idea.  But I'll
> push it soon.
>
> #if IS_ENABLED(CONFIG)
> function returns error pointer or valid
> #else
> struct foo *function() { return NULL; }
> #endif
>
> I believe that there are also people who use a two pass Coccinelle
> system where they make a list of functions that return error pointers
> and then check the callers.
>
> The Huawei devs find a bunch of these bugs through static analysis but
> I don't know which tools they are using.


Hi Dan,


We are using Coccinelle script to found them.


First step we using coccinelle script to found all the functions return

ERR_PTR or NULL, and do filter by checking all the users:  at least we

found at least 5 callers, and all the caller check only NULL or ERR_PTR,

then we add them to function list.


Then using coccinelle script do analysis base on the function list give

in step 1. Just do the same thing like smatch.


Regards,

Wei Yongjun


  reply	other threads:[~2021-06-23  2:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 14:31 [PATCH] media: v4l2-subdev: fix some NULL vs IS_ERR() checks Dan Carpenter
2021-06-22 15:08 ` Laurent Pinchart
2021-06-22 15:58   ` Dan Carpenter
2021-06-23  2:29     ` weiyongjun (A) [this message]
2021-06-23  2:34     ` Laurent Pinchart
2021-06-23  9:03       ` Dan Carpenter
2021-06-23 12:56         ` Laurent Pinchart
2021-06-22 20:01 ` Sakari Ailus

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=623db5b4-77e6-9fbf-37b4-6d6e2925ad84@huawei.com \
    --to=weiyongjun1@huawei.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.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).