From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>,
Wolfram Sang <wsa@the-dreams.de>, Sasha Levin <sashal@kernel.org>,
linux-i2c@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 07/13] i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr
Date: Sat, 8 Jun 2019 07:48:39 -0400 [thread overview]
Message-ID: <20190608114847.9973-7-sashal@kernel.org> (raw)
In-Reply-To: <20190608114847.9973-1-sashal@kernel.org>
From: Yingjoe Chen <yingjoe.chen@mediatek.com>
[ Upstream commit a0692f0eef91354b62c2b4c94954536536be5425 ]
If I2C_M_RECV_LEN check failed, msgs[i].buf allocated by memdup_user
will not be freed. Pump index up so it will be freed.
Fixes: 838bfa6049fb ("i2c-dev: Add support for I2C_M_RECV_LEN")
Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/i2c/i2c-dev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 57e3790c87b1..e56b774e7cf9 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -295,6 +295,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
rdwr_pa[i].buf[0] < 1 ||
rdwr_pa[i].len < rdwr_pa[i].buf[0] +
I2C_SMBUS_BLOCK_MAX) {
+ i++;
res = -EINVAL;
break;
}
--
2.20.1
next prev parent reply other threads:[~2019-06-08 11:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-08 11:48 [PATCH AUTOSEL 4.4 01/13] mISDN: make sure device name is NUL terminated Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 02/13] x86/CPU/AMD: Don't force the CPB cap when running under a hypervisor Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 03/13] perf/ring_buffer: Fix exposing a temporarily decreased data_head Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 04/13] perf/ring_buffer: Add ordering to rb->nest increment Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 05/13] gpio: fix gpio-adp5588 build errors Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 06/13] net: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE() Sasha Levin
2019-06-08 11:48 ` Sasha Levin [this message]
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 08/13] configfs: Fix use-after-free when accessing sd->s_dentry Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 09/13] ia64: fix build errors by exporting paddr_to_nid() Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 10/13] KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 11/13] net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 12/13] scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route() Sasha Levin
2019-06-08 11:48 ` [PATCH AUTOSEL 4.4 13/13] scsi: libsas: delete sas port if expander discover failed 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=20190608114847.9973-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wsa@the-dreams.de \
--cc=yingjoe.chen@mediatek.com \
/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
Powered by JetHome