linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Colin Ian King <colin.king@canonical.com>,
	Michael Moese <mmoese@suse.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-serial@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 22/38] 8250-men-mcb: fix error checking when get_num_ports returns -ENODEV
Date: Wed, 30 Oct 2019 11:53:50 -0400	[thread overview]
Message-ID: <20191030155406.10109-22-sashal@kernel.org> (raw)
In-Reply-To: <20191030155406.10109-1-sashal@kernel.org>

From: Colin Ian King <colin.king@canonical.com>

[ Upstream commit f50b6805dbb993152025ec04dea094c40cc93a0c ]

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: e2fea54e4592 ("8250-men-mcb: add support for 16z025 and 16z057")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Michael Moese <mmoese@suse.de>
Link: https://lore.kernel.org/r/20191013220016.9369-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/serial/8250/8250_men_mcb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c
index 127017cc41d92..057b1eaf6d2eb 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -71,8 +71,8 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 {
 	struct serial_8250_men_mcb_data *data;
 	struct resource *mem;
-	unsigned int num_ports;
-	unsigned int i;
+	int num_ports;
+	int i;
 	void __iomem *membase;
 
 	mem = mcb_get_resource(mdev, IORESOURCE_MEM);
@@ -87,7 +87,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 	dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n",
 		mdev->id, num_ports);
 
-	if (num_ports == 0 || num_ports > 4) {
+	if (num_ports <= 0 || num_ports > 4) {
 		dev_err(&mdev->dev, "unexpected number of ports: %u\n",
 			num_ports);
 		return -ENODEV;
@@ -132,7 +132,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 
 static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
 {
-	unsigned int num_ports, i;
+	int num_ports, i;
 	struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);
 
 	if (!data)
-- 
2.20.1


  parent reply	other threads:[~2019-10-30 16:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 15:53 [PATCH AUTOSEL 4.19 01/38] regulator: of: fix suspend-min/max-voltage parsing Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 02/38] ASoC: wm8994: Do not register inapplicable controls for WM1811 Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 03/38] arm64: dts: allwinner: a64: pine64-plus: Add PHY regulator delay Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 04/38] arm64: dts: allwinner: a64: sopine-baseboard: " Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 05/38] arm64: dts: Fix gpio to pinmux mapping Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 06/38] regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 07/38] ASoC: rt5682: add NULL handler to set_jack function Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 08/38] regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 09/38] ASoC: wm_adsp: Don't generate kcontrols without READ flags Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 10/38] ASoc: rockchip: i2s: Fix RPM imbalance Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 11/38] ARM: dts: logicpd-torpedo-som: Remove twl_keypad Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 12/38] pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable() Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 13/38] ARM: mm: fix alignment handler faults under memory pressure Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 14/38] scsi: qla2xxx: fix a potential NULL pointer dereference Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 15/38] scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 16/38] scsi: sni_53c710: fix compilation error Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 17/38] scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 18/38] ARM: 8914/1: NOMMU: Fix exc_ret for XIP Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 19/38] ARM: dts: imx7s: Correct GPT's ipg clock source Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 20/38] perf c2c: Fix memory leak in build_cl_output() Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 21/38] USB: legousbtower: fix a signedness bug in tower_probe() Sasha Levin
2019-10-30 15:53 ` Sasha Levin [this message]
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 23/38] perf kmem: Fix memory leak in compact_gfp_flags() Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 24/38] ARM: davinci: dm365: Fix McBSP dma_slave_map entry Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 25/38] drm/amdgpu: fix potential VM faults Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 26/38] scsi: target: core: Do not overwrite CDB byte 1 Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 27/38] tracing: Fix "gfp_t" format for synthetic events Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 28/38] ARM: 8926/1: v7m: remove register save to stack before svc Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 29/38] of: unittest: fix memory leak in unittest_data_add Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 30/38] MIPS: bmips: mark exception vectors as char arrays Sasha Levin
2019-10-30 15:53 ` [PATCH AUTOSEL 4.19 31/38] irqchip/gic-v3-its: Use the exact ITSList for VMOVP Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 32/38] i2c: stm32f7: fix first byte to send in slave mode Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 33/38] i2c: stm32f7: fix a race in slave mode with arbitration loss irq Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 34/38] i2c: stm32f7: remove warning when compiling with W=1 Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 35/38] cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 36/38] nbd: protect cmd->status with cmd->lock Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 37/38] nbd: handle racing with error'ed out commands Sasha Levin
2019-10-30 15:54 ` [PATCH AUTOSEL 4.19 38/38] nbd: verify socket is supported during setup Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191030155406.10109-22-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=colin.king@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mmoese@suse.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).