From 0f9f74597dfa615d85a0673754cad8c32d8de3d9 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 16 May 2016 17:41:25 +0000 Subject: [PATCH] Only lock Giant when needed in the LinuxKPI. Suggested by: ngie @ MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/device.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index ccee7b4b124f..2f43d817f894 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -333,10 +333,11 @@ device_unregister(struct device *dev) bsddev = dev->bsddev; dev->bsddev = NULL; - mtx_lock(&Giant); - if (bsddev != NULL) + if (bsddev != NULL) { + mtx_lock(&Giant); device_delete_child(device_get_parent(bsddev), bsddev); - mtx_unlock(&Giant); + mtx_unlock(&Giant); + } put_device(dev); } @@ -348,10 +349,11 @@ device_del(struct device *dev) bsddev = dev->bsddev; dev->bsddev = NULL; - mtx_lock(&Giant); - if (bsddev != NULL) + if (bsddev != NULL) { + mtx_lock(&Giant); device_delete_child(device_get_parent(bsddev), bsddev); - mtx_unlock(&Giant); + mtx_unlock(&Giant); + } } struct device *device_create(struct class *class, struct device *parent,