From f8ce294c312b8d750dcc3768c7977348a6d70264 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Sun, 27 Jul 2014 10:45:40 +0200 Subject: [PATCH] Fix memory allocation checks in _init --- klgd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/klgd.c b/klgd.c index eea23a4..c1c84ca 100644 --- 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: -- 2.43.5