From 89559b37206a92ebdbc9435a24ccd4f286f18ab5 Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Sun, 30 Aug 2015 21:40:36 +0200 Subject: [PATCH] fix error path in hidpp10drv_probe If we goto err early then both dev and drv_data will contain garbage values. We free one and dereference the other. Let's null them and add proper checks. Signed-off-by: Thomas Hindoe Paaboel Andersen --- src/driver-hidpp10.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 37045e11..ec59f106 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -184,8 +184,8 @@ static int hidpp10drv_probe(struct ratbag_device *device, const struct ratbag_id id) { int rc; - struct hidpp10drv_data *drv_data; - struct hidpp10_device *dev; + struct hidpp10drv_data *drv_data = NULL; + struct hidpp10_device *dev = NULL; rc = ratbag_open_hidraw(device); if (rc) { @@ -229,7 +229,8 @@ hidpp10drv_probe(struct ratbag_device *device, const struct ratbag_id id) err: free(drv_data); ratbag_set_drv_data(device, NULL); - hidpp10_device_destroy(dev); + if (dev) + hidpp10_device_destroy(dev); return rc; }