lkml.org 
[lkml]   [2022]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.18 0780/1095] HID: amd_sfh: Add NULL check for hid device
    Date
    From: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

    [ Upstream commit 06aa2a43c307cf4096f422dcb575e5d2913e528f ]

    On removal of hid device during SFH set report may cause NULL pointer
    exception. Hence add NULL check for hid device before accessing.

    Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
    Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 12 ++++++++----
    1 file changed, 8 insertions(+), 4 deletions(-)

    diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
    index e2a9679e32be..54fe224050f9 100644
    --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
    +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
    @@ -100,11 +100,15 @@ static int amdtp_wait_for_response(struct hid_device *hid)

    void amdtp_hid_wakeup(struct hid_device *hid)
    {
    - struct amdtp_hid_data *hid_data = hid->driver_data;
    - struct amdtp_cl_data *cli_data = hid_data->cli_data;
    + struct amdtp_hid_data *hid_data;
    + struct amdtp_cl_data *cli_data;

    - cli_data->request_done[cli_data->cur_hid_dev] = true;
    - wake_up_interruptible(&hid_data->hid_wait);
    + if (hid) {
    + hid_data = hid->driver_data;
    + cli_data = hid_data->cli_data;
    + cli_data->request_done[cli_data->cur_hid_dev] = true;
    + wake_up_interruptible(&hid_data->hid_wait);
    + }
    }

    static struct hid_ll_driver amdtp_hid_ll_driver = {
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-16 00:20    [W:2.350 / U:0.896 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site