Bug 4203 - possible null-ptr-deref in cxl_pci_init_afu|adapter()
Summary: possible null-ptr-deref in cxl_pci_init_afu|adapter()
Status: NEW
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: general/others (show other bugs) general/others
Version: 5.10.y-15
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: maqiao
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-24 10:07 UTC by niuyachen
Modified: 2023-02-24 10:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description niuyachen inspur_group 2023-02-24 10:07:39 UTC
Description of problem:

 If device_register() fails in cxl_pci_afu|adapter(), the device
    is not added, device_unregister() 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 device_register() says, it should use put_device() to give
    up the reference in the error path. So split device_unregister() into
    device_del() and put_device(), then goes to put dev when register fails.