Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2661957imj; Mon, 11 Feb 2019 06:38:55 -0800 (PST) X-Google-Smtp-Source: AHgI3Iazdf9yPV3kwEHf3R21BwfJTi/kOhEJNpFKmM7N/SqvtqBCZM1s7vxfhxDz4Y+QeoRz312y X-Received: by 2002:a62:3a89:: with SMTP id v9mr7797492pfj.26.1549895935456; Mon, 11 Feb 2019 06:38:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895935; cv=none; d=google.com; s=arc-20160816; b=ET24Ip8igonLDoKsTlhssc4eorYL8yx8PYAH0H1GvqrtNFNqCuK+BuW8XjyQ1/VC1P 6zM+CQWb206pMxAr9rICmcO3d3yL6GFhvfu9bEUCS5E/YgYZCR1H6jwxNcP4aGzwAiB1 75MABEpfkgfyhGyBz2Cj3vxuc5RODF3MUHJtRsZQCeigLuNlznQ/Xwk5CQyUcLDYgGhi Srd7QJhCbBxB0OaRoBZvysIiO3BIaOiu1LwSpdeUm3gnSKUQFdGFwIZzedyx0EUYhaeT zJ/pGKrGd05yjm6yxqofY5GfuAglwlDTGU6GF/yI/YJUY4sugMFcAK5mgfIc3NAJJ3r9 DokA== 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=gN1Ev7mSwR/IAJwC2qkcdFMKh8dHneK5/pJwDMrIIaU=; b=fs9yJc1zoZdbnorte6egJuAFxq/tlrt96VgtKTwkushDO0QBeHJlq8rgsSQzvhX/CL 9unA6RTjlvPeYMj/c4DWpW5hL/YuPC7Bdiam2+dTPYwrnyydlB+hELnfLB1tmTtyP8I5 vBnjab9quD3dR9w0gqCnG5lv6c8XLdVyfg8U8QwdjnHA2msq4gvPpTPcU31Ua+8my9Sz JUybA9mUZlht6mVzihDqyE57tZhoW+Z3cIT0bDHNDCdZzqD3M+S/gfpHPaI9d39CeZhD ov1hfCLLXjjBHOrkx+TfAn/oxowAoQDqky6CtkNKKFGexiwmRusE0lVHtuKuuROBRxJB zcEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dXtD+vYH; 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 j14si7802786pgg.44.2019.02.11.06.38.39; Mon, 11 Feb 2019 06:38:55 -0800 (PST) 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=dXtD+vYH; 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 S1731546AbfBKOhv (ORCPT + 99 others); Mon, 11 Feb 2019 09:37:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:47304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731524AbfBKOhs (ORCPT ); Mon, 11 Feb 2019 09:37:48 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 DA36720844; Mon, 11 Feb 2019 14:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895867; bh=5Wz7R4jYFXzViboDSCx3FTdkCQNdbNhUfM7JYZoTQ2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dXtD+vYHcOwmQwJqtj/pUSYHtUlm1p1/mcM1XwlWvTd0w+YxaglA38pwH2DjYewlS NOkcmXpP5Fu2u4yYwqFoTRwvyZIHm5IoDHu6Ei5c1rpkAjdu5MVQkMyDXsJYqffVdi eIyakOrKaiM40cFeXUcbjmDdBKhcc+hy54jkZTaE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Brandt Subject: [PATCH 4.20 350/352] serial: sh-sci: Do not free irqs that have already been freed Date: Mon, 11 Feb 2019 15:19:37 +0100 Message-Id: <20190211141909.445654543@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Brandt commit 4d95987a32db53f3beca76f8c4c8309ef6a5f192 upstream. Since IRQs might be muxed on some parts, we need to pay attention when we are freeing them. Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20". Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts") Cc: stable Signed-off-by: Chris Brandt Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1921,7 +1921,7 @@ out_nomem: static void sci_free_irq(struct sci_port *port) { - int i; + int i, j; /* * Intentionally in reverse order so we iterate over the muxed @@ -1937,6 +1937,13 @@ static void sci_free_irq(struct sci_port if (unlikely(irq < 0)) continue; + /* Check if already freed (irq was muxed) */ + for (j = 0; j < i; j++) + if (port->irqs[j] == irq) + j = i + 1; + if (j > i) + continue; + free_irq(port->irqs[i], port); kfree(port->irqstr[i]);