Skip to content

Commit f50b680

Browse files
Colin Ian Kinggregkh
authored andcommitted
8250-men-mcb: fix error checking when get_num_ports returns -ENODEV
The current checking for failure on the number of ports fails when -ENODEV is returned from the call to get_num_ports. Fix this by making num_ports and loop counter i signed rather than unsigned ints. Also add check for num_ports being less than zero to check for -ve error returns. Addresses-Coverity: ("Unsigned compared against 0") Fixes: e2fea54 ("8250-men-mcb: add support for 16z025 and 16z057") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Michael Moese <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4f5cafb commit f50b680

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/tty/serial/8250/8250_men_mcb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
7272
{
7373
struct serial_8250_men_mcb_data *data;
7474
struct resource *mem;
75-
unsigned int num_ports;
76-
unsigned int i;
75+
int num_ports;
76+
int i;
7777
void __iomem *membase;
7878

7979
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
@@ -88,7 +88,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
8888
dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n",
8989
mdev->id, num_ports);
9090

91-
if (num_ports == 0 || num_ports > 4) {
91+
if (num_ports <= 0 || num_ports > 4) {
9292
dev_err(&mdev->dev, "unexpected number of ports: %u\n",
9393
num_ports);
9494
return -ENODEV;
@@ -133,7 +133,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
133133

134134
static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
135135
{
136-
unsigned int num_ports, i;
136+
int num_ports, i;
137137
struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);
138138

139139
if (!data)

0 commit comments

Comments
 (0)