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 <dan.carpen...@oracle.com>

diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
index 7c6a3c3167bd..5d163be98e9f 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)

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to