Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp999065yba; Thu, 4 Apr 2019 02:05:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzURAtzEnduAr8gaknSCp6m9zOGQE3Uf8465Hq+qBf5b2IC0wXkfxsidd/0BhQzfzNklz9s X-Received: by 2002:a17:902:2d01:: with SMTP id o1mr5210148plb.155.1554368751598; Thu, 04 Apr 2019 02:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368751; cv=none; d=google.com; s=arc-20160816; b=Qqfv2F7VIU/VqoShrOlhAcBtgVf3oKyglcA4yVsE1Pd/JnVaaq6AVJLDOXEo/3wBkm duqNCuCpDsfcWs1QiGDWHDUQppgQ/AesfDHuuvO8ro92aPwXUYmADbWL8lTT1MZ7Y80M wTosVZ70gMofOhxiavc1EDxmr6SSWIACD+6ygXjB1uqq5QLJQpbAxHM1prAnrm+UJEx7 RiQL/2++Y4Ona+YyHmkWqsrJK2uA4EY/JccZVZjAROUKRvkPF6eHvAcrnZg7JNJmtD7S J54kU39Vt2fhHLOx2bXvV+E3JtxjB7XPsowqSYI4HvwPNT16+OB5jImjnx1IaouJcSeU MnjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kjhyQw1cu1poPj6VHM1ibWB/3Cv7ZD+jUcOCgLmNeBg=; b=NP+mVMBYlR9T24W+Fig7kU/xO2g0IWD1fyBday6mavNShw/dtAD7dxIVKTWK2LjLnj +GWqyqa9w72R4pI9dcxnw0zutSs2oig/k0csZofYQPDxJ8zHj1pJPS2XwCBkLHqh2Mft VQk0gzF1OHjX+Xz/LERS17K3PrX0fPKgEBLJoT5lVaebthjeZaYfGaw5qcddFy+X8r/J svsM+oEi8stRU2GgOj7SfheceI+EFySuC9aZPfGHl7+E5xdCISU3LYx42Qku6/+9RYf4 Y+9XIX29XHs28bconEqrL4403PiiW7IhB26yIP6iB6KTrpaBL0rCTm/qYa96d+sNJaSl nXZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cd6V8eIm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si15941217pgo.317.2019.04.04.02.05.36; Thu, 04 Apr 2019 02:05:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cd6V8eIm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731873AbfDDJDw (ORCPT + 99 others); Thu, 4 Apr 2019 05:03:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731863AbfDDJDu (ORCPT ); Thu, 4 Apr 2019 05:03:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05B3821850; Thu, 4 Apr 2019 09:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368629; bh=JZ0dd2YjbJpGu6j5NSaPIqCAfkWJAE3jOWY497T0ymg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cd6V8eImFmynr3GI5jxtD3Bdrgs1oLDf1hh/lNThzHiOItBkrK9c4ngYqU+H6G+fV tu9575IA2K1raxZISWvAZYreMmM4csz18QWp/i5gfRHPcmYKedF6BBakt8fMh0AQrK D6fyEx3MGYylQmSOQjXLeb8dZqBrwWgJwlC5ptZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hong Liu , Hongyan Song , Srinivas Pandruvada , Jiri Kosina , Sasha Levin Subject: [PATCH 4.19 094/187] HID: intel-ish-hid: avoid binding wrong ishtp_cl_device Date: Thu, 4 Apr 2019 10:47:11 +0200 Message-Id: <20190404084607.586218230@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 0d28f49412405d87d3aae83da255070a46e67627 ] When performing a warm reset in ishtp bus driver, the ishtp_cl_device will not be removed, its fw_client still points to the already freed ishtp_device.fw_clients array. Later after driver finishing ishtp client enumeration, this dangling pointer may cause driver to bind the wrong ishtp_cl_device to the new client, causing wrong callback to be called for messages intended for the new client. This helps in development of firmware where frequent switching of firmwares is required without Linux reboot. Signed-off-by: Hong Liu Tested-by: Hongyan Song Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/intel-ish-hid/ishtp/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 2623a567ffba..f546635e9ac9 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -623,7 +623,8 @@ int ishtp_cl_device_bind(struct ishtp_cl *cl) spin_lock_irqsave(&cl->dev->device_list_lock, flags); list_for_each_entry(cl_device, &cl->dev->device_list, device_link) { - if (cl_device->fw_client->client_id == cl->fw_client_id) { + if (cl_device->fw_client && + cl_device->fw_client->client_id == cl->fw_client_id) { cl->device = cl_device; rv = 0; break; @@ -683,6 +684,7 @@ void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev, spin_lock_irqsave(&ishtp_dev->device_list_lock, flags); list_for_each_entry_safe(cl_device, n, &ishtp_dev->device_list, device_link) { + cl_device->fw_client = NULL; if (warm_reset && cl_device->reference_count) continue; -- 2.19.1