Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2232079ybi; Thu, 20 Jun 2019 11:17:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/JBvtnDQOYjSUuqsM2lCPHzCmvvrO0Invr/Mo9zP0+k0tMOg8R2rrF1RNwcSM4EAKvxRC X-Received: by 2002:a17:902:121:: with SMTP id 30mr120663445plb.314.1561054629554; Thu, 20 Jun 2019 11:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054629; cv=none; d=google.com; s=arc-20160816; b=i1ewzgW7/HDfIQVyMDyTjnHXYGob3znjWzcu6+6o6tZ3MAU99xp9eFdR6nBaKwVuVb 82eU6yHefLE2Rnohpk8GrlAor8jh0XtrRri8RUFb9DHW5GT505fNXSx77nySBKhFVPdF /E4rkTfdxvI9tboY9HtXVd3aTqs/lCg3uooi1NhMChHVo1ItjgkC4x75trei7gXFngjy G3UvJA41nzw3rd2oQ/9R7ppo8taWD/MfpI2QnWAesy4P8AMAAv0c6trom2LJp8/SPGwZ tJHEkUnIFFN2/6j5vYmlEtxqlYXElFjABiQLTLPxa5d4ClGYHNYeWGEpXoAnboMmEGEX 6bQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J7Z6NnOxB7wydYkPaHwLlk0kVTSmy9cL+WUNK04qAxs=; b=TxDFmPslkd+6PsuVl8AB6T/ZoVIZ6SqskcMc74DVKCk/3T8abZhsy7K1FqTsXMgUDy 0yKhxNyd2jpL1d0eoYT2SxjPn5U6YgPYghkod0obc9lEnJV5VnWGnGxiVzIQmM0Uz5zC 8ailg0oUsRKr6e2yfPK6ATMikv4P1ISVEZ8GAUZ9vBEMWSn10j/2Mxk9bHOE1y6hrXZR AL6NDcZG1Kr0AaAO1IT8eRPZ8nhbXiZzhon2NvTTzM7dtxtOCnuCMKxgRPmJ8eykRoip Yu1iLchrXLe2alezxKKRGF+xl7w3C6jWvnI9+3rTDO5QSz1stn2qmaJa214JiFwBacx4 UgRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YR089eZG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si349536pld.301.2019.06.20.11.16.54; Thu, 20 Jun 2019 11:17:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YR089eZG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbfFTSPj (ORCPT + 99 others); Thu, 20 Jun 2019 14:15:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:44474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729627AbfFTSPh (ORCPT ); Thu, 20 Jun 2019 14:15:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A4FE2082C; Thu, 20 Jun 2019 18:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054536; bh=ZNLpGD2Qmwj7p07ux6Tt5MCr2BG4AVR1RFrcd1bxSws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YR089eZG01h+Cp1TPUtPRMXBNvHL59xWENpVehow9Ou8rGBba8Q89kL4u0KViwFfi J+yTtAtHlB+SDHPT/kYufLZ+1GjCnkaKoTL1N4QcQtxS25gYfpJDFrwhJqY3uZPyVa LcbOLoIRZKjWjmN/8v8T3G30FKRiZ8WaH6sfRAhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yingjoe Chen , Wolfram Sang , Sasha Levin Subject: [PATCH 5.1 63/98] i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr Date: Thu, 20 Jun 2019 19:57:30 +0200 Message-Id: <20190620174352.273247343@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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 3f7b9af11137..776f36690448 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -283,6 +283,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, msgs[i].len < 1 || msgs[i].buf[0] < 1 || msgs[i].len < msgs[i].buf[0] + I2C_SMBUS_BLOCK_MAX) { + i++; res = -EINVAL; break; } -- 2.20.1