Only reset the driver to NULL on unusual exits

If a driver succeeded but then fails sanity checks, leave the driver set and
let the cleanup code handle the rest. Otherwise, memory allocated by the
driver's probe() function is never released.

Fixes a valgrind memory leak complaint when running tests for invalid devices
(e.g. device_profiles_num_0).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2017-07-24 10:31:50 +10:00
committed by Benjamin Tissoires
parent a9c4f46412
commit 5637755345

View File

@@ -328,9 +328,8 @@ ratbag_test_driver(struct ratbag_device *device,
log_error(ratbag, "%s: error opening hidraw node (%s)\n",
device->name, strerror(-rc));
error:
device->driver = NULL;
error:
return false;
}