]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: properly init driver-private storage
authorBert Vermeulen <redacted>
Thu, 2 Aug 2012 19:42:37 +0000 (21:42 +0200)
committerBert Vermeulen <redacted>
Fri, 3 Aug 2012 09:29:00 +0000 (11:29 +0200)
hardware/asix-sigma/asix-sigma.c

index 3538ae2cdaecc5a32a57a2b2dd13c4f2b304ce36..7c73a72313ba24f9ebd337bcc310098ace339feb 100644 (file)
@@ -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;