In the Linux kernel, the following vulnerability has been resolved: cxl: fix possible null-ptr-deref in cxlguestinitafu|adapter() If deviceregister() fails in cxlregisterafu|adapter(), the device is not added, deviceunregister() can not be called in the error path, otherwise it will cause a null-ptr-deref because of removing not added device. As comment of deviceregister() says, it should use putdevice() to give up the reference in the error path. So split deviceunregister() into devicedel() and putdevice(), then goes to put dev when register fails.