1
0
forked from drath/libratbag

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 <phomes@gmail.com>
This commit is contained in:
Thomas Hindoe Paaboel Andersen
2015-08-30 21:40:36 +02:00
parent ad0ac1b6ea
commit 89559b3720

View File

@@ -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;
}