rtc: cpcap: kfreeing devm allocated memory

We shouldn't kfree(rtc) because is devm_ managed memory.  It leads to a
double free.

Fixes: dd3bf50b35 ("rtc: cpcap: new rtc driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-By: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This commit is contained in:
Dan Carpenter 2017-03-14 10:56:30 +03:00 committed by Alexandre Belloni
parent 7a8128e2e2
commit 65e9e65ceb

View File

@ -266,10 +266,8 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc",
&cpcap_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtc_dev)) {
kfree(rtc);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
}
err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
if (err)