i2c: dev: check return value when calling dev_set_name()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 11 Apr 2022 18:07:51 +0000 (21:07 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:36:27 +0000 (09:36 +0200)
commitc74d77a2d07744147d734138acd6ce9dba715e5d
treebc5b0edc9ad73af5dd05ae92d1d2088a20819d6d
parent4d485cf9b609709e45d5113e6e2b1b01254b2fe9
i2c: dev: check return value when calling dev_set_name()

commit 993eb48fa199b5f476df8204e652eff63dd19361 upstream.

If dev_set_name() fails, the dev_name() is null, check the return
value of dev_set_name() to avoid the null-ptr-deref.

Fixes: 1413ef638aba ("i2c: dev: Fix the race between the release of i2c_dev and cdev")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/i2c-dev.c