From 90b3d2f6c036042863c62a4314f0fce38cf395a4 Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Tue, 28 Nov 2017 00:10:32 +0100 Subject: sysfs: Use PTR_ERR_OR_ZERO() Fix ptr_ret.cocci warnings: fs/sysfs/group.c:409:8-14: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Signed-off-by: Vasyl Gomonovych Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index ac2de0ed69ad..3f8efe8f387b 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -406,6 +406,6 @@ int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, kernfs_put(entry); kernfs_put(target); - return IS_ERR(link) ? PTR_ERR(link) : 0; + return PTR_ERR_OR_ZERO(link); } EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj); -- cgit v1.2.3 From 5d54f948aaac4a6ab6b908af379103559a5a002c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2018 15:57:59 +0100 Subject: sysfs: turn WARN() into pr_warn() It's not good to crash the machine if panic_on_warn() is set just because someone made a stupid mistake of trying to create a sysfs file with the same name of an existing one. This makes the automated testing tools a lot harder to find the real bugs in the kernel. So just print a warning out and dump the stack to get the attention of the developer that they did something foolish. Then keep on trucking, as this should not be a fatal error at all. Reported-by: Dmitry Vyukov Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/dir.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fs') diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 2b67bda2021b..3a36a48a4b3f 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -10,6 +10,7 @@ * Please see Documentation/filesystems/sysfs.txt for more information. */ +#define pr_fmt(fmt) "sysfs: " fmt #undef DEBUG #include @@ -27,8 +28,8 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name) if (buf) kernfs_path(parent, buf, PATH_MAX); - WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s/%s'\n", - buf, name); + pr_warn("cannot create duplicate filename '%s/%s'\n", buf, name); + dump_stack(); kfree(buf); } -- cgit v1.2.3 From 619daeeeb80f39bb037434598e489a88db14a95b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2018 16:18:13 +0100 Subject: sysfs: use SPDX identifiers Move the license "mark" of the sysfs files to be in SPDX form, instead of the custom text that it currently is in. This is in a quest to get rid of the 700+ different ways we say "GPLv2" in the kernel tree. Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/dir.c | 3 +-- fs/sysfs/file.c | 3 +-- fs/sysfs/group.c | 4 +--- fs/sysfs/mount.c | 3 +-- fs/sysfs/symlink.c | 3 +-- fs/sysfs/sysfs.h | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) (limited to 'fs') diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 3a36a48a4b3f..c9877fc1c5fe 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * fs/sysfs/dir.c - sysfs core and dir operation implementation * @@ -5,8 +6,6 @@ * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo * - * This file is released under the GPLv2. - * * Please see Documentation/filesystems/sysfs.txt for more information. */ diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 39c75a86c67f..39da8e86f10a 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * fs/sysfs/file.c - sysfs regular (text) file implementation * @@ -5,8 +6,6 @@ * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo * - * This file is released under the GPLv2. - * * Please see Documentation/filesystems/sysfs.txt for more information. */ diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 3f8efe8f387b..4802ec0e1e3a 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * fs/sysfs/group.c - Operations for adding/removing multiple files at once. * @@ -5,9 +6,6 @@ * Copyright (c) 2003 Open Source Development Lab * Copyright (c) 2013 Greg Kroah-Hartman * Copyright (c) 2013 The Linux Foundation - * - * This file is released undert the GPL v2. - * */ #include diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index fb49510c5dcf..1823a1be492e 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * fs/sysfs/symlink.c - operations for initializing and mounting sysfs * @@ -5,8 +6,6 @@ * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo * - * This file is released under the GPLv2. - * * Please see Documentation/filesystems/sysfs.txt for more information. */ diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index aecb15f84557..8664db25a9a6 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * fs/sysfs/symlink.c - sysfs symlink implementation * @@ -5,8 +6,6 @@ * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo * - * This file is released under the GPLv2. - * * Please see Documentation/filesystems/sysfs.txt for more information. */ diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 0e2f1cccb812..d098e015fcc9 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h @@ -1,11 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * fs/sysfs/sysfs.h - sysfs internal header file * * Copyright (c) 2001-3 Patrick Mochel * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo - * - * This file is released under the GPLv2. */ #ifndef __SYSFS_INTERNAL_H -- cgit v1.2.3 From 78fae52cf46680e310cae168ff7bc88912350878 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2018 16:21:53 +0100 Subject: sysfs: remove DEBUG defines It isn't needed at all in these files, dynamic debug is the best way to enable this type of thing, if you really want it. As it is, these defines were not doing anything at all. Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/dir.c | 1 - fs/sysfs/mount.c | 2 -- 2 files changed, 3 deletions(-) (limited to 'fs') diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index c9877fc1c5fe..58eba92a0e41 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -10,7 +10,6 @@ */ #define pr_fmt(fmt) "sysfs: " fmt -#undef DEBUG #include #include diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 1823a1be492e..b428d317ae92 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c @@ -9,8 +9,6 @@ * Please see Documentation/filesystems/sysfs.txt for more information. */ -#define DEBUG - #include #include #include -- cgit v1.2.3