[PATCH v2 09/16] infiniband: utilize the new cdev_set_parent function

2017-02-25 Thread Logan Gunthorpe
This replaces the suspect looking cdev.kobj.parent lines with the equivalent cdev_set_parent function. This is a straightforward change that's largely cosmetic but it does push the kobj.parent ownership into char_dev.c where it belongs. Signed-off-by: Logan Gunthorpe ---

[PATCH v2 07/16] platform/chrome: cros_ec_dev - utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. At the same time we cleanup the error path through device_probe

[PATCH v2 01/16] chardev: add helper function to register char devs with a struct device

2017-02-25 Thread Logan Gunthorpe
Credit for this patch goes is shared with Dan Williams [1]. I've taken things one step further to make the helper function more useful and clean up calling code. There's a common pattern in the kernel whereby a struct cdev is placed in a structure along side a struct device which manages the

[PATCH v2 12/16] mtd: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
This is not as straightforward a conversion as the others in this series. These drivers did not originally make use of kobj.parent so they likely suffered from a use after free bug if someone unregistered the devices while they are being used. In order to make the conversions, switch from

[PATCH v2 10/16] iio:core: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. In doing so we have to remove a guard statement from cdev_del, but

[PATCH v2 16/16] switchtec: utilize new device_add_cdev helper function

2017-02-25 Thread Logan Gunthorpe
Very straightforward conversion to device_add_cdev. Drop cdev_add and device_add and use cdev_device_add. Signed-off-by: Logan Gunthorpe --- drivers/pci/switch/switchtec.c | 15 --- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git

[PATCH v2 08/16] IB/ucm: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
From: Jason Gunthorpe The use after free is not triggerable here because the cdev holds the module lock and the only device_unregister is only triggered by module unload, however make the change for consistency. To make this work the cdev_del needs to move out

[PATCH v2 06/16] tpm-chip: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. Signed-off-by: Logan Gunthorpe ---

[PATCH v2 11/16] media: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. Signed-off-by: Logan Gunthorpe ---

[PATCH v2 15/16] scsi: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
This driver did not set kobj.parent so it likely suffered from a potential use after free race if the user unregistered the device while it was in use. This was not so straightforward a conversion but I think this patch cleans up its probe's error path significantly. This patch adds

[PATCH v2 03/16] device-dax: utilize new cdev_device_add helper function

2017-02-25 Thread Logan Gunthorpe
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. Signed-off-by: Logan Gunthorpe ---