Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2524793imu; Thu, 29 Nov 2018 06:24:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/W/YeOGqYvkK4EfBLxR985PpOSHiOiqdmL/qlFk3qodYzXBBkL1voYlktOJVtfgKtrhF2Xf X-Received: by 2002:a62:2c4d:: with SMTP id s74mr1586828pfs.6.1543501451379; Thu, 29 Nov 2018 06:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501451; cv=none; d=google.com; s=arc-20160816; b=E37d9m1sbWDCvzBTv+xWRRg4Olv7MFDjT1Rq77jaM/tOMt5CAOGOk6hmbgY8vb4jSY c+DiX03jH1XysfZliFndPN/TtmCf6u/tW0t+JnUlnCFjoTj8yCeJGQUzb2+xaVPNWgVC 8AyrDo+sgaLlcYhx7iJo1BMefz7JoZ1Rl/pkNfW1YTAnEOnvGUpU+MyUWYaSc6eW7g0J IFHPcA155FVSx4U3Wn2mNERxKSgxSl32QcPpH2cEM4iwZMduj9c913sBzbE5cPTnRTli ncRPBTVkh+wFFSK9QbhdlxcvW41gzE7iUYqEDs8ICPTEaep/eyp47JVHT2JNE1fKy3v9 jyPA== 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=/M5I6ygFXdfBKhdWrBlWubLEXCoFGinlcohg1l6jtT8=; b=OMq7hEgefWZiOY/CtdBV1N+cj05BSD4i3N1hTwuJDUpU5dCfAiWl3aapxOyRGqhJM5 emi+e9I5RqqtRci1nFZbwjZxFEwsErPcFNqtrGZyH0azrVF9EliOPz1pN8XvOxN4P4K+ SBsay1LdKufprwgNs/vILZoKj9N6RnKTLJvg9k7mRlJpNdMcRHiJiqZ3BIB+9cF5ip2Y xe7u1zrkjQLrHV8l7hxN2C3GeKypxABlMi8zzoz+3BkROCpLh4SYKb7S7AfthfpuCwdt EnZ1aSJYXAcBZlwXxmZUumnLVlzDZr2KKgrz2Whw3L4lo4gBbSFWxiRFzBblHZc5sXaf hVJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VbiQZFTO; 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 f21si2127096pgb.371.2018.11.29.06.23.55; Thu, 29 Nov 2018 06:24:11 -0800 (PST) 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=VbiQZFTO; 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 S1731693AbeK3B1D (ORCPT + 99 others); Thu, 29 Nov 2018 20:27:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:51634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730358AbeK3B1D (ORCPT ); Thu, 29 Nov 2018 20:27:03 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 4A0D820868; Thu, 29 Nov 2018 14:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501291; bh=eBoHjWFOHLdkyJA9Ao2Lu/zr71RHMq1X891DCmIGDR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VbiQZFTOQY3DvYw12VNaVjV6Q9UuYPYzWVVuE9rp7Xov/5mbJp70iu9CZ8nKOj3OC hgQDkBhHkW/rOdh2SfHbuYlJT8KxGivE6oSJKtxXHx1iL7y7AMJpGlEJWy++n1ZBTR DUy+OtLRHvSSsQuJXeyasBTSGSmFJA36QekWXVCs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xulin Sun , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.9 31/92] rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write Date: Thu, 29 Nov 2018 15:12:00 +0100 Message-Id: <20181129140108.955413577@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140106.520639693@linuxfoundation.org> References: <20181129140106.520639693@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 9bde0afb7a906f1dabdba37162551565740b862d ] pcf2127_i2c_gather_write() allocates memory as local variable for i2c_master_send(), after finishing the master transfer, the allocated memory should be freed. The kmemleak is reported: unreferenced object 0xffff80231e7dba80 (size 64): comm "hwclock", pid 27762, jiffies 4296880075 (age 356.944s) hex dump (first 32 bytes): 03 00 12 03 19 02 11 13 00 80 98 18 00 00 ff ff ................ 00 50 00 00 00 00 00 00 02 00 00 00 00 00 00 00 .P.............. backtrace: [] create_object+0xf8/0x278 [] kmemleak_alloc+0x74/0xa0 [] __kmalloc+0x1ac/0x348 [] pcf2127_i2c_gather_write+0x54/0xf8 [] _regmap_raw_write+0x464/0x850 [] regmap_bulk_write+0x1a4/0x348 [] pcf2127_rtc_set_time+0xac/0xe8 [] rtc_set_time+0x80/0x138 [] rtc_dev_ioctl+0x398/0x610 [] do_vfs_ioctl+0xb0/0x848 [] SyS_ioctl+0x8c/0xa8 [] el0_svc_naked+0x34/0x38 [] 0xffffffffffffffff Signed-off-by: Xulin Sun Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-pcf2127.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c index 2bfdf638b673..8a3667e761dd 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -237,6 +237,9 @@ static int pcf2127_i2c_gather_write(void *context, memcpy(buf + 1, val, val_size); ret = i2c_master_send(client, buf, val_size + 1); + + kfree(buf); + if (ret != val_size + 1) return ret < 0 ? ret : -EIO; -- 2.17.1