kernel: fix cryptodev with kernel >= 2.6.35
[openwrt/openwrt.git] / target / linux / generic / files / crypto / ocf / cryptodev.c
index c1e9140a050be5a59f561cbcd0cc4c47dd8ebf0e..f7ce06bc120fb701e7a3b0a204c0f4183b113bb5 100644 (file)
@@ -977,10 +977,16 @@ cryptodev_open(struct inode *inode, struct file *filp)
        struct fcrypt *fcr;
 
        dprintk("%s()\n", __FUNCTION__);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+       /*
+        * on 2.6.35 private_data points to a miscdevice structure, we override
+        * it,  which is currently safe to do.
+        */
        if (filp->private_data) {
-               printk("cryptodev: Private data already exists !\n");
-               return(0);
+               printk("cryptodev: Private data already exists - %p!\n", filp->private_data);
+               return(-ENODEV);
        }
+#endif
 
        fcr = kmalloc(sizeof(*fcr), GFP_KERNEL);
        if (!fcr) {