Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1344135imm; Tue, 2 Oct 2018 06:51:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Kk40YKBRzH57EiJBlu/ozaQcEJByEkH+k5oON5dfoX0aGTYjp/W3y6hCjbFAY2I9D9ZNi X-Received: by 2002:a63:d109:: with SMTP id k9-v6mr14749058pgg.49.1538488271790; Tue, 02 Oct 2018 06:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488271; cv=none; d=google.com; s=arc-20160816; b=EtzA05hdlCwZFqRT7Uy4Je1que+DlvEW5eswGZwxknu5JmcMxOjvYFKF/A6mVKUV0e DVhw26waknp0Jjavsf/Bv0g7ignGE+VvkBZ9CHyvm70ZrCKyxVNgDYq9O1xXo5bKaTCM 0lkCvza2AFETrxqUiiQFy3iFvKOpcF6z8EqSAKxS4tdBzDLlI57Kb3/KjUvcXFPRfuuV pmPWgxA4BDh4N2c5ZWcbcLyw/ZuDCFqTZy09OeqQRi6PGOmx15zoqMMzT866EQYLNTKG eyIDFq6Qg99Xu8B2MmZabB8Ndr1i3cnTv6ures/dOvJ4nJjvgbH1Gn1Hoe2CG0rY7Lc/ UA5Q== 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; bh=uGj6bnDLpNjVW3ndgfffBlUrthr6GjteyxlpSqW2MbA=; b=oXxJ/dr19ofB+fxWkUqeCYlsTN30Yyw9STi9Oer+iTd4DQr1s+l8nzdNSBzp4YsQbt u9iI1VhChjWLo6Zr8Jr8UpuCfrbsbb8JiiEhWqbWferP1st5HtzANsCs95Jpy6FpHYe7 8zSikFLFxTDAIzpLW1m6AMTdFKxkd3c65J3QBuUk00ZJN2GXQQxiFGevK/z3AK6v27bL j9lgix2XtYoDrvrblnjo/5XGPXgjmdDbrKkgrbo5nvGB4KRuwgcEIe5C9hKiN3kxmBi7 ptnjD60vXKUqka4bg1fL3dpFJHuL3hh8OsDpfkVcpzHP15YqNppfLhr33i3OzJ/J/E42 Gkbw== ARC-Authentication-Results: i=1; mx.google.com; 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 c6-v6si286065pfg.2.2018.10.02.06.50.56; Tue, 02 Oct 2018 06:51:11 -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; 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 S1732046AbeJBURR (ORCPT + 99 others); Tue, 2 Oct 2018 16:17:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35092 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732031AbeJBURQ (ORCPT ); Tue, 2 Oct 2018 16:17:16 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3281D5AA; Tue, 2 Oct 2018 13:33:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Shishkin Subject: [PATCH 4.14 087/137] intel_th: Fix device removal logic Date: Tue, 2 Oct 2018 06:24:48 -0700 Message-Id: <20181002132504.613268310@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132458.446916963@linuxfoundation.org> References: <20181002132458.446916963@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Shishkin commit 8801922cd94c918e4dc3a108ecaa500c4d40583f upstream. Commit a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices") brings in new subdevice addition/removal logic that's broken for "host mode": the SWITCH device has no children to begin with, which is not handled in the code. This results in a null dereference bug later down the path. This patch fixes the subdevice removal code to handle host mode correctly. Signed-off-by: Alexander Shishkin Fixes: a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices") CC: stable@vger.kernel.org # v4.14+ Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/intel_th/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -147,7 +147,8 @@ static int intel_th_remove(struct device th->thdev[i] = NULL; } - th->num_thdevs = lowest; + if (lowest >= 0) + th->num_thdevs = lowest; } if (thdrv->attr_group)