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 <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-12-05 15:16:52 -06:00 committed by Uwe Hermann
parent 63c07e48c6
commit 26be4ebef3
1 changed files with 4 additions and 0 deletions

View File

@ -151,6 +151,10 @@ static int clear_instances(void)
struct dev_context *devc; struct dev_context *devc;
GSList *l; GSList *l;
/* di is not necessarily initialized */
if (!di)
return SR_OK;
if (!(drvc = di->priv)) if (!(drvc = di->priv))
return SR_OK; return SR_OK;