OSDN Git Service

driver core: Don't ignore class_dir_create_and_add() failure.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 7 May 2018 10:10:31 +0000 (19:10 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 May 2018 14:37:46 +0000 (16:37 +0200)
commit84d0c27d6233a9ba0578b20f5a09701eb66cee42
treed7da3b81c9654509f1db78e986e4975e2a69b8e2
parentcd4846c5a68da77705164924f47001af3b499dec
driver core: Don't ignore class_dir_create_and_add() failure.

syzbot is hitting WARN() at kernfs_add_one() [1].
This is because kernfs_create_link() is confused by previous device_add()
call which continued without setting dev->kobj.parent field when
get_device_parent() failed by memory allocation fault injection.
Fix this by propagating the error from class_dir_create_and_add() to
the calllers of get_device_parent().

[1] https://syzkaller.appspot.com/bug?id=fae0fb607989ea744526d1c082a5b8de6529116f

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+df47f81c226b31d89fb1@syzkaller.appspotmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c