From: Gerhard Sittig Date: Fri, 9 Feb 2018 18:30:45 +0000 (+0100) Subject: tondaj-sl-814: fix a potential memory leak X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2da5c95f3dc6ad0c9067e23c46ae643958fca015;p=libsigrok.git tondaj-sl-814: fix a potential memory leak Release an allocated device instance in an error path. This was reported by clang's scan-build. --- diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index d7192a21..bc6fa18e 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -82,8 +82,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) serial = sr_serial_dev_inst_new(conn, serialcomm); - if (serial_open(serial, SERIAL_RDWR) != SR_OK) + if (serial_open(serial, SERIAL_RDWR) != SR_OK) { + g_free(sdi); return NULL; + } sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial;