Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2530646imu; Thu, 29 Nov 2018 06:28:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZSyWkqyj0whCWz06J3Ha6VD+PJiEAnuED4hX1rA5k5OwmDp031D9Xy9Twort8vVlgRRjU X-Received: by 2002:a63:dd15:: with SMTP id t21mr1360349pgg.347.1543501735057; Thu, 29 Nov 2018 06:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501735; cv=none; d=google.com; s=arc-20160816; b=vW8M95+I/uymx8D0PZue3Fa4JU64OiSxD5H/GTAOkWoAmXcPjaDoqJTYIU5qkOSkcE 2m+CCUPT9uMsYxFJ0vbuIrP5vYi+8KOHOQXojkN8JB4TWuHdv0O4W55W9vjgdYsVpng7 rYFLubIwbUvOBYX+7X1IDuugmlWJjb+YZ22K10m9rYQFJCurhfZhUTKuM7gErqWOOo+c 26nS502tmxfqSpWC76RYmB6U3e5M22n81D50f3l+wLjAcFGAAKUPZIYkQ22naruVPhDa xRNQO7Gsm73go6W3ie101ZGg9ROnOxedAXx6uwRkR8DDmINYnf6mKSPxv+OBGj/Mnef4 UIUw== 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=kSav2QWRVPBosfmKTzdRSaRdU1d+8p7VlXMUNwI6wao=; b=PimeO5MMGpR6noQw5ZijphjzpovmwJQhw1ahqL9V1FswFVdYWELRK89bUaHREGCRp8 sTKoX1D+Z5rwua2I+kJ8tt7B6s21jAtX4sWcSAuPawYY7TYNFuHd/IcEwvPnto/yFR2v TbCQpLQ+WCSHQVcO9fHa+Vn5KlCo9wUdGRSFdfM1XI/RbpEJgwR0rsM7mVCbjoCGQgOw TId6TFFNznjSKBaMEZ9HA0h6rnXfTCFWMN/Z+JefM0AEEeE9I5dF1LRgnTwGUCn2KGrx uGUqL+A7Rmoo6E9svNQT69ZTdcBYtDdKfJn4qsCtZRdDiBSi5SeNPDcPqTm7L1jZ4izT wxkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xqMFk1a8; 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 i20si2211955pgh.187.2018.11.29.06.28.39; Thu, 29 Nov 2018 06:28:55 -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=xqMFk1a8; 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 S2387478AbeK3BcT (ORCPT + 99 others); Thu, 29 Nov 2018 20:32:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:60374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732836AbeK3BcS (ORCPT ); Thu, 29 Nov 2018 20:32:18 -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 DE8FE2145D; Thu, 29 Nov 2018 14:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501606; bh=ZST52MH9OuKRPyPvhpQl1YL3zFssz/EG2st8E5ufpOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqMFk1a89jqihV61JWX4/lQ2GtOWKlXE9ft1Qu5aQTCPKizKy9owC0erUnt152hHm zsg2VHk+3tgt256L7brMQf8HM4rb01VQWO6a6wgqQjBHR+c9hJ6KHldoF0I3RnuxKy HQi1sgWrioC3YvatVCnUtNSIy0K5xgh/Yn6YbGxE= 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.14 049/100] rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write Date: Thu, 29 Nov 2018 15:12:19 +0100 Message-Id: <20181129140103.410471153@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@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.14-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 f33447c5db85..9f1b14bf91ae 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -248,6 +248,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