mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 22:42:04 +00:00
tty: rpmsg: Assign returned id to a local variable
Instead of putting garbage in the data structure, assign allocated id or an error code to a temporary variable. This makes code cleaner. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20211025135148.53944-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6333a48506
commit
0572da285d
@ -121,15 +121,16 @@ static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mutex_lock(&idr_lock);
|
||||
cport->id = idr_alloc(&tty_idr, cport, 0, MAX_TTY_RPMSG, GFP_KERNEL);
|
||||
err = idr_alloc(&tty_idr, cport, 0, MAX_TTY_RPMSG, GFP_KERNEL);
|
||||
mutex_unlock(&idr_lock);
|
||||
|
||||
if (cport->id < 0) {
|
||||
err = cport->id;
|
||||
if (err < 0) {
|
||||
kfree(cport);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
cport->id = err;
|
||||
|
||||
return cport;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user