Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2535896imu; Thu, 29 Nov 2018 06:32:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/VQcj5kTd/ZlkMVVDGVOHXg6YVHwR28leBPt14Pjn2Icrkkw3prUgEf7HhcLF1yHxuB9EFK X-Received: by 2002:a63:78cd:: with SMTP id t196mr1464725pgc.62.1543501979441; Thu, 29 Nov 2018 06:32:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501979; cv=none; d=google.com; s=arc-20160816; b=BuFRIRhqxel6q0p1eL9JgEs6/DEz2ENRNre2FStVuQJK/jgZaU3udY6azS0azVgWKK GtK+GvCFYFzI4fUl9ICUhp6inFMhV57Sv9ehQElAM87Lp2mlxzz9I7yiBswGCvRkkV6j mOJv2z3Gt0G6C2OQe7bsvYQnHRwfhJwBAL/LkJsSO60Vaj4pfcP1GS+TyfpnGY2Y5zr9 aC/llH02DLyS5i0WgJtrAmZOq+Uhf0anR35f/ObnG2iAPZmJ+avxBdfgb4xaXfnFXyN+ wac6xEjFohFDuwowHv7/REjSls6rPmyNKSO1MQXWv1G3ybRrFVooebxZA+uWXsJYm7Rl Q0Sg== 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=b0qf/bHkYyH+NNZ70lq6xNaSQ+5CttEOnHBYIpW+5RI=; b=LNA6NeCpxLN37EOI87P5JREvdEXdWysD/UJOBshmvSXh5v+J2se2cGXZjXX8PCneSh bNEtnGvpKzdvjz0HUngzR8DzSdWxuA7QqRUztB8DAOA64YdnWRw8VjJ5mnISXHFNehR5 P+HJA3RhZrqsArCU4XP1RcVQEGVTuxeQYI16BXjdR6tPsHmuE+2bfxOilbi1ROBNgEa2 v1YWfKmjNUuslo4dPmL5IJcus666d7mUNFh78p3YrvqW40M73DYIN0EpVf+QPNNhHbFx Q0451vQ7gIaYQzCjAEmaZ4PlyNK2IFy0oNNVzVIB1+vH2W6dR2bishyrLdkrk760Rjik FtUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IpSuzS0A; 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 u6si2499150pfb.92.2018.11.29.06.32.43; Thu, 29 Nov 2018 06:32:59 -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=IpSuzS0A; 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 S2389088AbeK3Bgu (ORCPT + 99 others); Thu, 29 Nov 2018 20:36:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:39362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389059AbeK3Bgr (ORCPT ); Thu, 29 Nov 2018 20:36:47 -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 B58A32145D; Thu, 29 Nov 2018 14:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501874; bh=AZFx8sEXbdXqld8v8Q/Ni1z/uzfifQfN8bcoC7rE25c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IpSuzS0AgZtEfjFo+CpZCf7uOyypNaql9maFaC+D55rRGY+uWd7CIf0GbJgmi0Ilx wfAxXUDZc2uDlGheQ6eHBXXWibEkmEA7XSCwkLZ9zHulzFYQostEn2NHJhGeg1RCHj LYJH4eu1gANh6JV6PGHIZ0mL29rfieLRotJDAPns= 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.19 076/110] rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write Date: Thu, 29 Nov 2018 15:12:47 +0100 Message-Id: <20181129135924.322300259@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@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.19-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 9f99a0966550..7cb786d76e3c 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -303,6 +303,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