Skip to content
Commit 12280cc7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman
Browse files

parport: Clean up resources correctly when parport_register_port() fails

The smatch warns about uncleaned resources in case the
parport_register_port() fails:

  parport_register_port() warn: '&tmp->full_list' not removed from list

This is indeed an issue introduced when converting code to use
kasprintf(). However, the whole kasprintf() dance in this case
is not needed as dev_set_name() can handle the formatted input
and produces the same result. So, the solution is to delegate
name forming to the dev_set_name() and make device_register()
error path to deal with error handling (via put_device() call).

Fixes: 8d8ae17e

 ("parport: Use kasprintf() instead of fixed buffer formatting")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202310180809.hepZB9k6-lkp@intel.com/
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231018145948.1367648-1-andriy.shevchenko@linux.intel.com
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 63ba2d07
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment