fix below warnings:
sensor-dev.c:1016 gyro_dev_ioctl() warn: inconsistent returns 'mutex:&sensor->operation_mutex'.
Locked on: line 973
line 982
Unlocked on: line 919
line 1010
line 1016
sensor-dev.c:1905 sensor_probe() error: potential null dereference 'sensor->input_dev'. (input_allocate_device returns null)
sensor-dev.c:1905 sensor_probe() error: we previously assumed 'sensor->input_dev' could be null (see line 1902)
sensor-dev.c:2051 sensor_probe() error: don't call input_free_device() after input_unregister_device()
sensor-dev.c:2080 sensor_remove() error: don't call input_free_device() after input_unregister_device()
Change-Id: I7da8a337282df7f9b8e6474a68928fc53d4e6890
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit
08fd14ea02692f43eaa8a166791cdaaa4b6c0738)
result = sensor->status_cur;\r
if (copy_to_user(argp, &result, sizeof(result)))\r
{\r
result = sensor->status_cur;\r
if (copy_to_user(argp, &result, sizeof(result)))\r
{\r
+ mutex_unlock(&sensor->operation_mutex);\r
printk("%s:failed to copy sense data to user space.\n",__FUNCTION__);\r
return -EFAULT;\r
}\r
printk("%s:failed to copy sense data to user space.\n",__FUNCTION__);\r
return -EFAULT;\r
}\r
DBG("%s:L3G4200D_IOCTL_SET_ENABLE OK\n", __func__);\r
break;\r
case L3G4200D_IOCTL_SET_DELAY: \r
DBG("%s:L3G4200D_IOCTL_SET_ENABLE OK\n", __func__);\r
break;\r
case L3G4200D_IOCTL_SET_DELAY: \r
- mutex_lock(&sensor->operation_mutex);\r
if (copy_from_user(&rate, argp, sizeof(rate)))\r
return -EFAULT;\r
if (copy_from_user(&rate, argp, sizeof(rate)))\r
return -EFAULT;\r
+ mutex_lock(&sensor->operation_mutex);\r
if(sensor->status_cur == SENSOR_OFF)\r
{\r
if ( (result = sensor->ops->active(client, 1, rate) ) < 0 ) {\r
if(sensor->status_cur == SENSOR_OFF)\r
{\r
if ( (result = sensor->ops->active(client, 1, rate) ) < 0 ) {\r
if(result < 0)\r
goto out_free_memory;\r
\r
if(result < 0)\r
goto out_free_memory;\r
\r
- sensor->input_dev = input_allocate_device();\r
+ sensor->input_dev = devm_input_allocate_device(&client->dev);\r
if (!sensor->input_dev) {\r
result = -ENOMEM;\r
dev_err(&client->dev,\r
if (!sensor->input_dev) {\r
result = -ENOMEM;\r
dev_err(&client->dev,\r
- "Failed to allocate input device %s\n", sensor->input_dev->name);\r
+ "Failed to allocate input device\n");\r
goto out_free_memory;\r
} \r
\r
goto out_free_memory;\r
} \r
\r
return result;\r
\r
out_misc_device_register_device_failed:\r
return result;\r
\r
out_misc_device_register_device_failed:\r
- input_unregister_device(sensor->input_dev); \r
out_input_register_device_failed:\r
out_input_register_device_failed:\r
- input_free_device(sensor->input_dev); \r
out_no_free:\r
dev_err(&client->adapter->dev, "%s failed %d\n\n", __func__, result);\r
return result;\r
out_no_free:\r
dev_err(&client->adapter->dev, "%s failed %d\n\n", __func__, result);\r
return result;\r
\r
cancel_delayed_work_sync(&sensor->delaywork);\r
misc_deregister(&sensor->miscdev);\r
\r
cancel_delayed_work_sync(&sensor->delaywork);\r
misc_deregister(&sensor->miscdev);\r
- input_unregister_device(sensor->input_dev); \r
- input_free_device(sensor->input_dev); \r
- kfree(sensor);\r
#ifdef CONFIG_HAS_EARLYSUSPEND\r
if((sensor->ops->suspend) && (sensor->ops->resume))\r
unregister_early_suspend(&sensor->early_suspend);\r
#ifdef CONFIG_HAS_EARLYSUSPEND\r
if((sensor->ops->suspend) && (sensor->ops->resume))\r
unregister_early_suspend(&sensor->early_suspend);\r