]> sigrok.org Git - libsigrok.git/commitdiff
ols: fixed *ctx null dereferences that would SEGFAULT on probing for a OLS or attempt...
authorMatt Ranostay <redacted>
Fri, 9 Mar 2012 06:26:30 +0000 (22:26 -0800)
committerMatt Ranostay <redacted>
Fri, 9 Mar 2012 06:27:33 +0000 (22:27 -0800)
Signed-off-by: Matt Ranostay <redacted>
hardware/openbench-logic-sniffer/ols.c

index 5d62d90192f2274a56204b76ae1aa5aa94d216bb..1a9b5555eb463ca7d2912f1a7689fb80fab2f165 100644 (file)
@@ -445,6 +445,7 @@ static int hw_init(const char *devinfo)
                        /* got metadata */
                        sdi = get_metadata(fds[i].fd);
                        sdi->index = final_devcnt;
+                       ctx = sdi->priv;
                } else {
                        /* not an OLS -- some other board that uses the sump protocol */
                        sdi = sr_dev_inst_new(final_devcnt, SR_ST_INACTIVE,
@@ -705,10 +706,11 @@ static int receive_data(int fd, int revents, void *cb_data)
        ctx = NULL;
        for (l = dev_insts; l; l = l->next) {
                sdi = l->data;
+               ctx = sdi->priv;
                if (ctx->serial->fd == fd) {
-                       ctx = sdi->priv;
                        break;
                }
+               ctx = NULL;
        }
        if (!ctx)
                /* Shouldn't happen. */