Skip to content

Commit

Permalink
ser_gigaset: fix deallocation of platform device structure
Browse files Browse the repository at this point in the history
When shutting down the device, the struct ser_cardstate must not be
kfree()d immediately after the call to platform_device_unregister()
since the embedded struct platform_device is still in use.
Move the kfree() call to the release method instead.

Signed-off-by: Tilman Schmidt <[email protected]>
Fixes: 2869b23 ("drivers/isdn/gigaset: new M101 driver (v2)")
Reported-by: Sasha Levin <[email protected]>
Signed-off-by: Paul Bolle <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tilmanschmidt authored and davem330 committed Dec 15, 2015
1 parent ede03d3 commit 4c5e354
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/isdn/gigaset/ser-gigaset.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,19 +368,23 @@ static void gigaset_freecshw(struct cardstate *cs)
tasklet_kill(&cs->write_tasklet);
if (!cs->hw.ser)
return;
dev_set_drvdata(&cs->hw.ser->dev.dev, NULL);
platform_device_unregister(&cs->hw.ser->dev);
kfree(cs->hw.ser);
cs->hw.ser = NULL;
}

static void gigaset_device_release(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct cardstate *cs = dev_get_drvdata(dev);

/* adapted from platform_device_release() in drivers/base/platform.c */
kfree(dev->platform_data);
kfree(pdev->resource);

if (!cs)
return;
dev_set_drvdata(dev, NULL);
kfree(cs->hw.ser);
cs->hw.ser = NULL;
}

/*
Expand Down

0 comments on commit 4c5e354

Please sign in to comment.