From: Bert Vermeulen Date: Thu, 2 Aug 2012 19:42:37 +0000 (+0200) Subject: asix-sigma: properly init driver-private storage X-Git-Tag: dsupstream~746 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b32503cccdf88769619dc9a2ca3566d06040c1b4;p=libsigrok.git asix-sigma: properly init driver-private storage --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 3538ae2c..7c73a723 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -437,8 +437,13 @@ static void clear_instances(void) static int hw_init(void) { + struct drv_context *drvc; - /* Nothing to do. */ + if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { + sr_err("asix-sigma: driver context malloc failed."); + return SR_ERR; + } + adi->priv = drvc; return SR_OK; } @@ -780,6 +785,9 @@ static int hw_dev_close(struct sr_dev_inst *sdi) static int hw_cleanup(void) { + if (!adi->priv) + return SR_OK; + clear_instances(); return SR_OK;