From 26be4ebef369e465eb5f13ee7bbab71b62e455f6 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Wed, 5 Dec 2012 15:16:52 -0600 Subject: [PATCH] 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 --- hardware/serial-dmm/api.c | 4 ++++ 1 file changed, 4 insertions(+) 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;