Skip to content

Commit

Permalink
serial: port: Make ->iotype validation global in __uart_read_properti…
Browse files Browse the repository at this point in the history
…es()

In order to make code robust against potential changes in the future
move ->iotype validation outside of switch in __uart_read_properties().
If any code will be added in between that might leave the ->iotype value
unknown the validation catches this up.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250124161530.398361-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Feb 4, 2025
1 parent e8486bd commit 1239754
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/tty/serial/serial_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,15 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults)
break;
default:
port->iotype = UPIO_UNKNOWN;
if (!use_defaults) {
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
return -EINVAL;
}
break;
}
}

if (!use_defaults && port->iotype == UPIO_UNKNOWN) {
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
return -EINVAL;
}

/* Read the address mapping base offset (default: no offset) */
ret = device_property_read_u32(dev, "reg-offset", &value);
if (ret)
Expand Down

0 comments on commit 1239754

Please sign in to comment.