From: Alexandru Gagniuc Date: Wed, 5 Dec 2012 21:16:52 +0000 (-0600) Subject: serial-dmm: Fix segfault when no device is used X-Git-Tag: dsupstream~471 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=26be4ebef369e465eb5f13ee7bbab71b62e455f6 serial-dmm: Fix segfault when no device is used di was initialized as NULL. If no device covered by this driver is used, di remains NULL. This causes a segmentation fault when calling clear_instances(). Check for di being NULL. Signed-off-by: Alexandru Gagniuc --- diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index 8a2d7be2..be240e23 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -151,6 +151,10 @@ static int clear_instances(void) struct dev_context *devc; GSList *l; + /* di is not necessarily initialized */ + if (!di) + return SR_OK; + if (!(drvc = di->priv)) return SR_OK;