From 5c0dbe4d5c7283c71d5a6cee4b2bce521023af87 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 27 Apr 2017 11:28:52 +1000 Subject: [PATCH] hidpp20: fix dereference before null check Found by coverity Signed-off-by: Peter Hutterer --- src/driver-hidpp20.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index ec2b03b4..27da53ac 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -909,12 +909,15 @@ hidpp20_log(void *userdata, enum hidpp_log_priority priority, const char *format static void hidpp20drv_remove(struct ratbag_device *device) { - struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device); - struct hidpp20_device *dev = drv_data->dev; + struct hidpp20drv_data *drv_data; + struct hidpp20_device *dev; if (!device) return; + drv_data = ratbag_get_drv_data(device); + dev = drv_data->dev; + ratbag_close_hidraw(device); if (drv_data->profiles)