mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jiri Kosina <jkosina@suse.cz>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	WANG Cong <xiyou.wangcong@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>, Tejun Heo <tj@kernel.org>,
	Julia Lawall <julia@diku.dk>
Subject: Re: [PATCH] base firmware: Fix BUG from sysfs attributes change in commit a2db6842873c8e5a70652f278d469128cb52db70
Date: Mon, 15 Mar 2010 01:48:50 +0100	[thread overview]
Message-ID: <20100315004850.GB28894@pengutronix.de> (raw)
In-Reply-To: <m1fx42yb3s.fsf@fess.ebiederm.org>

[-- Attachment #1: Type: text/plain, Size: 3225 bytes --]

On Sun, Mar 14, 2010 at 12:08:55PM -0700, Eric W. Biederman wrote:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> 
> > On Sun, 14 Mar 2010, Wolfram Sang wrote:
> >>
> >> coccinelle can apply semantic patches, rough description here [1]. So I wrote
> >> one which checks for every c-file in the kernel-tree:
> >>
> >> - Is there a structure containing (bin_)attribute?
> >> - Does a function declare a pointer to such a structure?
> >> - Is this pointer then used for a sysfs_create(_bin)_file?
> >> - If so, has there been a call to sysfs(_bin)_attr_init before?
> >>
> >> If not -> report. As coccinelle works on an abstract level of the code (not on
> >> source-code level), it can follow code-paths and such. Really nice tool, once
> >> you gathered the information to learn it.
> 
> Any chance you can post the semantic patch?  If it isn't too hard it
> would be nice to have the warm fuzzy of running it myself and seeing
> that there are no more of these left in the kernel.

(Strange, I sent an introductory message to the series:

http://kerneltrap.org/mailarchive/linux-kernel-janitors/2010/3/12/6848563

But it doesn't show up in the gmane-archives? And I just learned that CCs added
while editing the introductory message will be dropped by git-send-email. This
is why it isn't on lkml. I have to fix that next time.)

Sure, reviewing is very welcome. I am still new to the semantic patches, so a
double check is surely helpful (also adding Julia Lawall to cc, grand master of
this topic).

Here is the patch again for the binary-attributes (I recommend coccinelle
v0.2.2. Run it with 'spatch -sp_file <name> .' form kernel-top-level-dir):

@ init @
identifier struct_name, bin;
@@

        struct struct_name {
                ...
                struct bin_attribute bin;
                ...
        };

@ main extends init @
expression E;
statement S;
identifier name, err;
@@

(
        struct struct_name *name;
|
-       struct struct_name *name = NULL;
+       struct struct_name *name;
)
        ...
(
        sysfs_bin_attr_init(&name->bin);
|
+       sysfs_bin_attr_init(&name->bin);
        if (sysfs_create_bin_file(E, &name->bin))
                S
|
+       sysfs_bin_attr_init(&name->bin);
        err = sysfs_create_bin_file(E, &name->bin);
)


Here is my patch for the non-binary-attributes:

@ init @
identifier struct_name, attr;
@@

        struct struct_name {
                ...
                struct attribute attr;
                ...
        };

@ main extends init @
expression E;
statement S;
identifier name, err;
@@

(
        struct struct_name *name;
|
-       struct struct_name *name = NULL;
+       struct struct_name *name;
)
        ...
(
        sysfs_attr_init(&name->attr);
|
+       sysfs_attr_init(&name->attr);
        if (sysfs_create_file(E, &name->attr))
                S
|
+       sysfs_attr_init(&name->attr);
        err = sysfs_create_file(E, &name->attr);
)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2010-03-15  0:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-13 19:36 Larry Finger
2010-03-13 22:32 ` Linus Torvalds
2010-03-13 22:39   ` Jiri Kosina
2010-03-13 22:57     ` Linus Torvalds
2010-03-14  3:57       ` Eric W. Biederman
2010-03-14  5:46         ` Linus Torvalds
2010-03-14  6:59           ` Ingo Molnar
2010-03-14 17:20             ` Linus Torvalds
2010-03-14 18:11           ` Greg KH
2010-03-14 18:30             ` Eric W. Biederman
2010-03-14 18:38               ` Greg KH
2010-03-14 10:49         ` Wolfram Sang
2010-03-14 18:04           ` Linus Torvalds
2010-03-14 18:07             ` Linus Torvalds
2010-03-14 19:08             ` Eric W. Biederman
2010-03-15  0:48               ` Wolfram Sang [this message]
2010-03-15  0:20             ` Wolfram Sang
2010-03-15  0:29             ` [PATCH] init dynamic bin_attribute structures Wolfram Sang
2010-03-15 10:00               ` Jiri Kosina
2010-03-15 10:12                 ` [rtc-linux] " Wolfram Sang
2010-03-15 18:47                 ` Linus Torvalds
2010-03-13 22:55   ` [PATCH] base firmware: Fix BUG from sysfs attributes change in commit a2db6842873c8e5a70652f278d469128cb52db70 Larry Finger

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=20100315004850.GB28894@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=Larry.Finger@lwfinger.net \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@suse.de \
    --cc=jkosina@suse.cz \
    --cc=julia@diku.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=xiyou.wangcong@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

all inboxes | Powered by JetHome®