Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2981134rwb; Mon, 15 Aug 2022 15:23:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GgIJm+hI5azroUH6hM4Ft5Ms0ZrbqjI/5XW2QtVotf9SWabBFrbeRNY0H3O1ypfDGwN/D X-Received: by 2002:a17:906:7e43:b0:738:6395:8d94 with SMTP id z3-20020a1709067e4300b0073863958d94mr2796140ejr.54.1660602184949; Mon, 15 Aug 2022 15:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660602184; cv=none; d=google.com; s=arc-20160816; b=GRtINMj6EOknw9zIfy9TkT7CSOOKjxfq214QSBvh/3H5zCdDueXTEI9w9h+PXrWi8H 8nsdWqxYcNrwXqwmQ72LKXqGBNX9ry99uDwcmjgLgC3uOzoq08KNrfWIbqQ9lybILoXR 4NxPEa1Mgs0p2/lseNuLuynCaq4imcSs0JblnWuF/3C8y+GKC7qDvePU8VNY5mfyuFrL oxPzNCtd75l0Hb4w53Oko+QzzpWkHX2yn9MvKEGVu50lLnas62BUkOp5McJR7zi4XqGp ISkE4ied93QOL+6oH0mwlnBGhXqWjbO1Z5knJPF3p0qb0JDxNG8SsgcxCSIYOpoH1FYh boMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B3/KsINb7ZGVgTC3GHjUjOwAJYnn40PYBmlcGaYlMB4=; b=FPAFwWnj4tbzWFWW8jVhQ+gEAh6I77AVM4ijTlgG8KTa+A0mtyoEgt0mD3wzMByN7t VDmXXFMlJ7nXAHFr9Da5cQ9kGOIVlpp5JgoRRFZ8+ExqkMMyy2h8u7BmvddmxcFarbds hsnQbBTy8Y1LSVvwIscDxjSH/hOeoBUT5sVtkJxcuK9NcKnLXLbqqV7aCkz4fSvASX0X hhGAooNpvtPvDRLUTxpXW9a1N6cTa+Tg+QZkiyxE0YTbNkXSFn3gFiQjVh0QGAeD7FXK sNu1yPXYYY58CuNgvlBZ6JTG5llOo3pXE1uFSrH4t93nRAAfN7v60Jon5qc3pobl7IPg EsxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PmPxvpXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l4-20020a056402124400b0043c2dd3d889si8177180edw.428.2022.08.15.15.22.39; Mon, 15 Aug 2022 15:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PmPxvpXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347942AbiHOWUZ (ORCPT + 99 others); Mon, 15 Aug 2022 18:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348183AbiHOWQV (ORCPT ); Mon, 15 Aug 2022 18:16:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E9707A75C; Mon, 15 Aug 2022 12:40:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C845B611F6; Mon, 15 Aug 2022 19:39:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4A74C433C1; Mon, 15 Aug 2022 19:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592394; bh=Lt3I10bBaab6peJvJL+7PA1gYSbRnSA2Jze6Kx9+sVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmPxvpXWHMww+jpn09hObe32/+sWaBSLvZ7thlNqmpfLropxZK6dISWyGD9dN7c+P tm7V0nHNnFsMtPUdpKkV34o1ugNkrAPn5ssNzNR4zWu6khO8n0/tfGl0rgUuHwg5gd KR2BtRu8YG7rPdLLpOmepxg9L5uTQ0iGt72UwHzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Basavaraj Natikar , Jiri Kosina , Sasha Levin Subject: [PATCH 5.18 0780/1095] HID: amd_sfh: Add NULL check for hid device Date: Mon, 15 Aug 2022 20:02:59 +0200 Message-Id: <20220815180501.524385994@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Basavaraj Natikar [ 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 Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- 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