From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755468AbcBEQGe (ORCPT ); Fri, 5 Feb 2016 11:06:34 -0500 Received: from lb3-smtp-cloud6.xs4all.net ([194.109.24.31]:46635 "EHLO lb3-smtp-cloud6.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754279AbcBEQGc (ORCPT ); Fri, 5 Feb 2016 11:06:32 -0500 Message-ID: <1454688387.28847.34.camel@tiscali.nl> Subject: Re: gigaset: memory leak in gigaset_initcshw From: Paul Bolle To: Dmitry Vyukov Cc: Karsten Keil , "David S. Miller" , gigaset307x-common@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com, Kostya Serebryany , Alexander Potapenko , Sasha Levin Date: Fri, 05 Feb 2016 17:06:27 +0100 In-Reply-To: References: <1454516189.14366.8.camel@tiscali.nl> <1454526665.14366.22.camel@tiscali.nl> <1454591389.14366.49.camel@tiscali.nl> <1454593604.14366.65.camel@tiscali.nl> <1454598375.14366.72.camel@tiscali.nl> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 (3.16.5-3.fc22) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, (If anyone is confused by this conversation: Dmitry replied to an off list message.) On vr, 2016-02-05 at 14:28 +0100, Dmitry Vyukov wrote: > I wonder why you don't see the leak I am seeing... So do I, for a few days now. > are you suing qemu or real hardware? I am using qemu. Real hardware (a ThinkPad). Probably less powerful that your VM. What is the rate you're seeing leakage of a struct ser_cardstate? I'm running your latest test at about 2.000 TIOCSETD's per second - which is by itself not very useful for our driver - and notice no _obvious_ leakage when I do that for a few minutes. I do note the hardware screaming to just keep up with the abuse, though. > I've added the following change: > > --- a/drivers/isdn/gigaset/ser-gigaset.c > +++ b/drivers/isdn/gigaset/ser-gigaset.c > @@ -396,6 +396,7 @@ static int gigaset_initcshw(struct cardstate *cs) > pr_err("out of memory\n"); > return -ENOMEM; > } > + WARN_ON(cs->hw.ser != NULL); > cs->hw.ser = scs; > > cs->hw.ser->dev.name = GIGASET_MODULENAME; > > and it does fire. > Can it be a case that free_cs() runs before gigaset_device_release()? gigaset_device_release() is the release operation that is run when our struct device goes away. The core code is responsible for calling it, we can't be certain when that will happen. At least, we should not expect it to happen directly after calling platform_device_unregister(). (It was actually syzkaller that warned us that we did just that until recently. See commit 4c5e354a9742 ("ser_gigaset: fix deallocation of platform device structure").) > If that would happen, then cs can be reused while the previous > cs->hw.ser is not freed yet. Just a guess. I'll have to ponder on that a bit, sorry. Paul Bolle