From 65e9e65cebbea755db638875a44b227a1027570e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 14 Mar 2017 10:56:30 +0300 Subject: [PATCH] rtc: cpcap: kfreeing devm allocated memory We shouldn't kfree(rtc) because is devm_ managed memory. It leads to a double free. Fixes: dd3bf50b35e3 ("rtc: cpcap: new rtc driver") Signed-off-by: Dan Carpenter Acked-By: Sebastian Reichel Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-cpcap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c index 7c6a3c3..5d163be9 100644 --- a/drivers/rtc/rtc-cpcap.c +++ b/drivers/rtc/rtc-cpcap.c @@ -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) -- 2.7.4