[PATCH] kobject: don't use WARN for registration failures

From: Dmitry Vyukov
Date: Wed Apr 11 2018 - 11:22:57 EST


This WARNING proved to be noisy. The function still returns an error
and callers should handle it. That's how most of kernel code works.
Downgrade the WARNING to pr_err() and leave WARNINGs for kernel bugs.

Signed-off-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Reported-by: syzbot+209c0f67f99fec8eb14b@xxxxxxxxxxxxxxxxxxxxxxxxx
Reported-by: syzbot+7fb6d9525a4528104e05@xxxxxxxxxxxxxxxxxxxxxxxxx
Reported-by: syzbot+2e63711063e2d8f9ea27@xxxxxxxxxxxxxxxxxxxxxxxxx
Reported-by: syzbot+de73361ee4971b6e6f75@xxxxxxxxxxxxxxxxxxxxxxxxx

---

For the record, here are only currently open syzbot bugs for this WARNING
(not counting older bugs and various duplicates). None of them were
acted on:

WARNING: kobject bug in gfs2_sys_fs_add
https://syzkaller.appspot.com/bug?id=057673a56dab61b3a447989b67f10b205111c8f4

WARNING: kobject bug in br_add_if
https://syzkaller.appspot.com/bug?id=3e0339080acd6a2a350a900bc6533b03f5498490

WARNING: kobject bug in netdev_queue_update_kobjects
https://syzkaller.appspot.com/bug?id=86a8e2ab50527d5a5eb4fad2fc15df609f22d86a

WARNING: kobject bug in device_add
https://syzkaller.appspot.com/bug?id=57eba87aff7669512fb68e56a932b01805342d13

For context see discussion here:
https://groups.google.com/d/msg/syzkaller-bugs/JZ9QSEaA_HA/wWvpywtBBQAJ
---
lib/kobject.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index e1d1f290bf35..18989b5b3b56 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -233,13 +233,12 @@ static int kobject_add_internal(struct kobject *kobj)

/* be noisy on error issues */
if (error == -EEXIST)
- WARN(1,
- "%s failed for %s with -EEXIST, don't try to register things with the same name in the same directory.\n",
- __func__, kobject_name(kobj));
+ pr_err("%s failed for %s with -EEXIST, don't try to register things with the same name in the same directory.\n",
+ __func__, kobject_name(kobj));
else
- WARN(1, "%s failed for %s (error: %d parent: %s)\n",
- __func__, kobject_name(kobj), error,
- parent ? kobject_name(parent) : "'none'");
+ pr_err("%s failed for %s (error: %d parent: %s)\n",
+ __func__, kobject_name(kobj), error,
+ parent ? kobject_name(parent) : "'none'");
} else
kobj->state_in_sysfs = 1;

--
2.17.0.484.g0c8726318c-goog