]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
asix-sigma: properly init driver-private storage
[libsigrok.git] / 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;