From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754114AbcBESgH (ORCPT ); Fri, 5 Feb 2016 13:36:07 -0500 Received: from lb2-smtp-cloud6.xs4all.net ([194.109.24.28]:36798 "EHLO lb2-smtp-cloud6.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752056AbcBESgF (ORCPT ); Fri, 5 Feb 2016 13:36:05 -0500 Message-ID: <1454697361.28847.39.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 19:36:01 +0100 In-Reply-To: <1454688387.28847.34.camel@tiscali.nl> 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> <1454688387.28847.34.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 On vr, 2016-02-05 at 17:06 +0100, Paul Bolle wrote: > 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. This is from the hit-the-code-until-it-confesses department: --- a/drivers/isdn/gigaset/ser-gigaset.c +++ b/drivers/isdn/gigaset/ser-gigaset.c @@ -373,13 +373,9 @@ static void gigaset_freecshw(struct cardstate *cs) static void gigaset_device_release(struct device *dev) { - struct cardstate *cs = dev_get_drvdata(dev); - - if (!cs) - return; + struct ser_cardstate *scs = dev_get_drvdata(dev); dev_set_drvdata(dev, NULL); - kfree(cs->hw.ser); - cs->hw.ser = NULL; + kfree(scs); } /* @@ -408,7 +404,7 @@ static int gigaset_initcshw(struct cardstate *cs) cs->hw.ser = NULL; return rc; } - dev_set_drvdata(&cs->hw.ser->dev.dev, cs); + dev_set_drvdata(&cs->hw.ser->dev.dev, scs); tasklet_init(&cs->write_tasklet, gigaset_modem_fill, (unsigned long) cs); Does that make any difference? Paul Bolle