diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-10-25 15:51:44 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-26 19:19:41 +0200 |
commit | 0572da285d694e945303e74b7f9084b41e02ecbd (patch) | |
tree | 5543e7463e7e2be3f9c4e6442fe20961a8bff4e3 /drivers | |
parent | serial: stm32: push DMA RX data before suspending (diff) | |
download | linux-0572da285d694e945303e74b7f9084b41e02ecbd.tar.xz linux-0572da285d694e945303e74b7f9084b41e02ecbd.zip |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tty/rpmsg_tty.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/rpmsg_tty.c b/drivers/tty/rpmsg_tty.c index 813076341ffd..8c17ddbf371d 100644 --- a/drivers/tty/rpmsg_tty.c +++ b/drivers/tty/rpmsg_tty.c @@ -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; } |