Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5648165img; Wed, 27 Mar 2019 12:24:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWN4rWV32ucwuHRxn4Ls1jtebyrHlUH79yy+aBu45p6AMNZljTJv+L5W9maqoCqEYdsyW7 X-Received: by 2002:a17:902:7e05:: with SMTP id b5mr651527plm.127.1553714646247; Wed, 27 Mar 2019 12:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714646; cv=none; d=google.com; s=arc-20160816; b=zT/B+e/idLeAJodPdflQcQAzj3YgbsObFkMzQ5w0GbDTDtI8OPdZAZu6ELfNOwVXdh vNTNx3d56qBL4xU5MFdk8FuM7JGSsi3dbtbRblpB1gitFA+gNwJHev5KvqiT2uku1oVt jCLLtjDJGhYXPskZ3wsiWSZt2tAMq8pRu4ns7h2kWBaiTczBMU5dZYZ+nxfyC3zUW9fw lMg86OFc77h4YK2VMul5DnviWk19Zlx+FnPkl0sa3nm2HXO7Ey0eM68tePeRn851xj6x JeIm9DI/xRmm0aNDyRhSl0eMBPNqUfkUvE7ARBGY6UwXeGBT7PERLOTjarI8306qyKfQ C/UA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gFV2PS9km+Pg5mILmsVAF/3kVwWURQw6wBND+uuptx8=; b=pY7uaTGly+uCeZyXameRKrlEhDnerjDTmKuhqe4+iwp2sgO+Jft9svWFnVDfBx1DTI r9hjJYSI0aVAR/QxeFNlJeQZPadsZ24vxKM+1gzuDar8ha1hcO9i6eEQAxong+i96zue iXOnZH3FH1vhikOu0/p5sOmNelcA9PFympsIdSQsJCBod63KN/q5RhCKNNeg6uN1O/hn ENXFi3cN9MYPtFeYHjRyVre3xX9J4UrrAQ0e7+jMcOo175IcX7SinfwQ70yXCI5LuL0j lQIjhs95p/C1Y6cg/XYi3Qc3iEY7ojjDzfqmSuplpXiYRL76dCvekIRDoGGQrJeO6FkJ 17VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="f/bJcHCZ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si18610758pga.209.2019.03.27.12.23.50; Wed, 27 Mar 2019 12:24:06 -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="f/bJcHCZ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387861AbfC0SGG (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731654AbfC0SF7 (ORCPT ); Wed, 27 Mar 2019 14:05:59 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 160E4217D9; Wed, 27 Mar 2019 18:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709958; bh=RxrlnZXjmH34jj6R9z5NgZ+ymTAK0tSZy4lvusK7Z/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/bJcHCZZazTv/lPipGKABAN+k4NfrZMJLVys29fWUQQnnhYQ2P7BdoSk4YlIsIAx G70NzIfBc5bZreNBdutt0x/8wkAuN8BdjygaqoFZpdmNl3ZWo3WOHZ9n8Ks5/qO4MF Obs1EAC+luSUl6QvViliHZ0aywKIPXzywc+kslNs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hong Liu , Jiri Kosina , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 132/262] HID: intel-ish-hid: avoid binding wrong ishtp_cl_device Date: Wed, 27 Mar 2019 13:59:47 -0400 Message-Id: <20190327180158.10245-132-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hong Liu [ 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 728dc6d4561a..a271d6d169b1 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -675,7 +675,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; @@ -735,6 +736,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