Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7013435imm; Tue, 28 Aug 2018 05:08:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY2Tf8rlXmVTTmr4hY2ozDLfpm25Zn9C8EmYrzwZlzzH2/9wQEcBEQdOF3+hZwF+Url3osH X-Received: by 2002:a62:1391:: with SMTP id 17-v6mr1296064pft.34.1535458139815; Tue, 28 Aug 2018 05:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535458139; cv=none; d=google.com; s=arc-20160816; b=C3NbsMTc7Df3YXG4XML59vDdKrPxKfrj4bB4phoVkSkP6K+DeFacpWLGrWCyv33X/R c/GUqsu6cURT6mMof6RxoD1GL+JD4W8juv2BRbHSIaBoDRFOQwzKHk7EZGxOW4M1bvnL +yWIPeSg+OucLmtzhXSYoQi33hBIJu2urTxvzNKpMqS25i2eN+TYDyUFndS/3eQ1aQ3m 1sciF37ciV20JIwSc6fDLaGk0GTtGEUZ+h7rgAHoxPHBhQhi9GFQOmn5bSFdoMiiBes6 gO79c4rAXKNzbv/uLKsj6lMQQ/4SQbvpQ4t0xjUqi3liRgSeOzOZwhXtNzQGXbwU84vi A2EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=ybqDNG0M3v2s2EU1EimqXLolmIKl9K30IbulYCKozgs=; b=IgQTuGXzC3gC96FtNAzKsQUIxYUJM5u2e1eFqSjET3EUnn+izoetMHtFZQKqdt9JJJ C1QBAr6gUPA8S74W+oLtB8CwpUYhjNNulR6uV/CjoJxETMkMZ3pGynA3oMdI2x+VQ29t 4asBeBvGiz6lbvNR11ZbBmeXNjyzoFIvqNQlISF4n9NSGciqtlsssDpxP+Sn6IXL5bEO T0EHCVfQfjTATGSLW8Eqoc0/PbMebFsr9tpjUosZaJMICNN9BQeOPTITF8MIDWjd+UOT /6ec5F9pWFKs7Km30Tur1dBJLX1zYXYvQPp8ZpYEcqzQ3T1Mlm5brgEbZQ/5jIXVbgjM /GXQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si830808plh.324.2018.08.28.05.08.43; Tue, 28 Aug 2018 05:08:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727662AbeH1P67 (ORCPT + 99 others); Tue, 28 Aug 2018 11:58:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:56838 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727067AbeH1P67 (ORCPT ); Tue, 28 Aug 2018 11:58:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EB87CAF7E; Tue, 28 Aug 2018 12:07:36 +0000 (UTC) Date: Tue, 28 Aug 2018 14:07:35 +0200 (CEST) From: Jiri Kosina To: Stefan Agner cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: core: fix memory leak on probe In-Reply-To: <20180828112955.11318-1-stefan@agner.ch> Message-ID: References: <20180828112955.11318-1-stefan@agner.ch> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Aug 2018, Stefan Agner wrote: > The dynamically allocted collection stack does not get freed in > all situations. Make sure to also free the collection stack when > using the parser in hid_open_report(). > > Fixes: 08a8a7cf1459 ("HID: core: do not upper bound the collection stack") > Signed-off-by: Stefan Agner > --- > Found with kmemleak: > > unreferenced object 0xc57f0700 (size 64): > comm "kworker/0:1", pid 20, jiffies 131383 (age 28.750s) > hex dump (first 32 bytes): > 02 00 00 00 00 02 00 00 00 00 00 00 00 68 80 c5 .............h.. > 80 07 7f c5 01 00 00 00 08 48 80 c5 08 48 80 c5 .........H...H.. > backtrace: > [<1b437483>] __kmalloc_track_caller+0x1dc/0x300 > [] krealloc+0x54/0xc0 > [] hid_parser_main+0x258/0x2c8 > [<210b9aaa>] hid_open_report+0x134/0x2ac > [<61cd8964>] hid_generic_probe+0x20/0x38 > [] hid_device_probe+0xdc/0x13c > [<334f035e>] really_probe+0x1d8/0x2c4 > [<351dc2c0>] driver_probe_device+0x68/0x184 > [<7e3e3d3c>] __device_attach_driver+0xa0/0xd4 > [<1b053a89>] bus_for_each_drv+0x60/0xc0 > [<732716d8>] __device_attach+0xdc/0x144 > [] device_initial_probe+0x14/0x18 > [] bus_probe_device+0x90/0x98 > [] device_add+0x424/0x62c > [<46595a15>] hid_add_device+0x108/0x2b8 > [] usbhid_probe+0x2d4/0x3bc Also queued for 4.19. Thank you Stefan, -- Jiri Kosina SUSE Labs