Re: gigaset: memory leak in gigaset_initcshw
From: Paul Bolle
Date: Wed Feb 03 2016 - 14:11:14 EST
Hi Dmitry,
On wo, 2016-02-03 at 17:16 +0100, Paul Bolle wrote:
> The above should provide me with enough information to figure out
> what's going on here.
I've instrumented ser_gigaset with some printk's. Basically I added the
stuff pasted at the end of this message. In 10.000 runs of the program
syzkaller generated the added printk's suggest that struct ser_cardstate
is freed every time.
(Note that this was done on a machine that, probably like the VM
syzkaller was running in, doesn't have the clunky hardware that this
driver manages attached.)
Before I dive deeper into this: can you reproduce this leak? Is it
perhaps a one in gazillion runs thing? Do you have the logs of a run
that warned about this leak at hand?
Thanks,
Paul Bolle
@@ -375,9 +377,12 @@ static void gigaset_device_release(struct device *dev)
{
struct cardstate *cs = dev_get_drvdata(dev);
- if (!cs)
+ if (!cs) {
+ pr_info("%s: no cardstate", __func__);
return;
+ }
dev_set_drvdata(dev, NULL);
+ pr_info("%s: kfree(%p)", __func__, cs->hw.ser);
kfree(cs->hw.ser);
cs->hw.ser = NULL;
}
@@ -392,6 +397,7 @@ static int gigaset_initcshw(struct cardstate *cs)
struct ser_cardstate *scs;
scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL);
+ pr_info("%s: scs = %p", __func__, scs);
if (!scs) {
pr_err("out of memory\n");
return -ENOMEM;