]> Devoid-pointer.net GitWeb - KLGD.git/commitdiff
Fix memory allocation checks in _init
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 27 Jul 2014 08:45:40 +0000 (10:45 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 27 Jul 2014 08:45:40 +0000 (10:45 +0200)
klgd.c

diff --git a/klgd.c b/klgd.c
index eea23a4bb53790ac562203a9c46c266c43fe7d42..c1c84caf5e43b008321289a6792079d7131525b2 100644 (file)
--- a/klgd.c
+++ b/klgd.c
@@ -142,15 +142,18 @@ int klgd_init(struct klgd_main *ctx, void *dev_ctx, int (*callback)(void *, stru
                return -EINVAL;
 
        priv = kzalloc(sizeof(struct klgd_main_private), GFP_KERNEL);
-       if (!ctx->private)
+       if (!priv) {
+               printk(KERN_ERR "No memory for KLGD data\n");
                return -ENOMEM;
+       }
 
        mutex_init(&priv->stream_mlock);
        priv->wq = create_singlethread_workqueue("klgd_processing_loop");
        INIT_DELAYED_WORK(&priv->work, klgd_delayed_work);
 
        priv->plugins = kzalloc(sizeof(struct klgd_plugin *) * plugin_count, GFP_KERNEL);
-       if (!ctx->private->plugins) {
+       if (!priv->plugins) {
+               printk(KERN_ERR "No memory for KLGD plugins\n");
                ret = -ENOMEM;
                goto err_out;
        }
@@ -162,6 +165,7 @@ int klgd_init(struct klgd_main *ctx, void *dev_ctx, int (*callback)(void *, stru
        priv->send_command_stream = callback;
        priv->send_asap = 0;
 
+       ctx->private = priv;
        return 0;
 
 err_out: