Skip to content

Commit 1239754

Browse files
andy-shevgregkh
authored andcommitted
serial: port: Make ->iotype validation global in __uart_read_properties()
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e8486bd commit 1239754

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/tty/serial/serial_port.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,15 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults)
229229
break;
230230
default:
231231
port->iotype = UPIO_UNKNOWN;
232-
if (!use_defaults) {
233-
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
234-
return -EINVAL;
235-
}
236232
break;
237233
}
238234
}
239235

236+
if (!use_defaults && port->iotype == UPIO_UNKNOWN) {
237+
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
238+
return -EINVAL;
239+
}
240+
240241
/* Read the address mapping base offset (default: no offset) */
241242
ret = device_property_read_u32(dev, "reg-offset", &value);
242243
if (ret)

0 commit comments

Comments
 (0)