Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1193655ybn; Wed, 2 Oct 2019 12:14:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc/5QUZd0xFDcLkP5CAoNScYpqoKDAdfI7lOmY1At/eutB5XDHfezKSE21J+3U5JL/mz+x X-Received: by 2002:a50:f0dd:: with SMTP id a29mr5545057edm.219.1570043651078; Wed, 02 Oct 2019 12:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043651; cv=none; d=google.com; s=arc-20160816; b=HP69vMxCC/6O2qjI1/5OBp2TlgymlBLfP+WeU5qll54y3Gt9KFw4U5EScxWR8ZI2F0 L9kvVUQph+cGgFQsonqppknzQaK3eXrR9pMNmXZcrzgAZvoE0Cy2oV5Ry+XffaLRQzOI 6VDQN34D4eSrwn2gbwHS8EIuZTHk0n9BQz4AQ1d7Umd02ZHFp+584edocuDxUwwOhDS8 FwDeQdznUegK708H/ZR8TArtfezV//a0ZR2OIT1XzPJBX/96sXOnZxClthhPDyJPxB3H /fto+pzDlJNOmpMNgNb9VhEZczJW+j0777rVZpWTHK5e/QEKC5nZesfjZ1vSXndkgCR7 Afhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=x+oF+vgLBqlYYW1QPG1vYj+BTsb/wf8GrPAzoFr2mto=; b=VL7/K/zDcoQVAhPV9PMoRRYiv72gVI3HcEmG02fUonij/5M9nEku3sYEVOICnlwbEO dwQWvNmhbNFrSR0pOPftn4ne6lQg6XB9fDMsrVzNur/zpktMZae2ED5xkqFDy6fOaEKH 2ogFSBCcy7BLV6dzECZyr8X0XcLr1HWMTcOVHE6IwujZkKJY7uCooQ1zdzGs1/RIuUBN 7mOKYzctFuj9U+jq69KFP2ZOlT+HgV0RkmL3OTjIEsMTaHcOOsEm4m276YuPS7+I3XSJ nNQqbORXuZqVziYviHwN4BoYnvTl28GKzeCkGHe43/V+cnnO3KL6B8PBhHg0W2D59y4+ OCjA== ARC-Authentication-Results: i=1; mx.google.com; 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 e49si38220edb.87.2019.10.02.12.13.46; Wed, 02 Oct 2019 12:14:11 -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; 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 S1730084AbfJBTM0 (ORCPT + 99 others); Wed, 2 Oct 2019 15:12:26 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35470 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbfJBTIK (ORCPT ); Wed, 2 Oct 2019 15:08:10 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyo-000364-Ll; Wed, 02 Oct 2019 20:08:06 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyn-0003cL-T5; Wed, 02 Oct 2019 20:08:05 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Wolfram Sang" , "Yingjoe Chen" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 31/87] i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Yingjoe Chen commit a0692f0eef91354b62c2b4c94954536536be5425 upstream. 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: Ben Hutchings --- drivers/i2c/i2c-dev.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -300,6 +300,7 @@ static noinline int i2cdev_ioctl_rdrw(st rdwr_pa[i].buf[0] < 1 || rdwr_pa[i].len < rdwr_pa[i].buf[0] + I2C_SMBUS_BLOCK_MAX) { + i++; res = -EINVAL; break; }