Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1308686pxu; Mon, 23 Nov 2020 17:57:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgXBEhn2VD2mmoxnqw3slFi3HkiD6KRdAWm4FEiTt/QctzYM8qN3f7VVxOsdA7aU/7YrX0 X-Received: by 2002:a17:907:3d8b:: with SMTP id he11mr2152698ejc.207.1606183057433; Mon, 23 Nov 2020 17:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183057; cv=none; d=google.com; s=arc-20160816; b=TVCjmfJSuZL0WdpN0fV0cAjRsjqRwmiYM6wgvjpqkMjO6TRNVkOkFa22wh5/1GYIc5 LxEMdu2qJyAAHE+m/EPoj3rFtmoma9ngtZnuoQFzDwB8uhd0EnN34TSCBLgnYHRJO4Kv wCQKXvee7NINV9r8mYZ0TyyPOB5Q9+acAXWbtkV4eLnQb3AMu+m80Fdx2HVuJrf+iL9T 6iKynjEFgQ8CQGcOz8qL02tDX28mu6tFsfezRalpoD+YRguDapbzhHkEPKKf9+RK3TBs OyiDQq1c9gCgpgSqDxbJ89eJykJDZ/ZwQPUgqTRo5c7b1SeCoVQjFrjnrizMYMy3YJXo W/3A== 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=7SA0Nh3zrPlBx3rMVUAVzyGR88N9WTuG7hbr/JYJV1w=; b=OLcP0cRwQshqclsm6P+gMxtz7ORW9jRi0xrp4zBdXA0wuIPOVo1OBsZr71RD+FSAsH 6NYvA7u1NLIKYWWvAcJLVHDyeyGHpGhkqkGY512r4VuXc/67k6/Dk7Jo1Uhx48DwNz3S xOpwyHsn9xAnxWVj6twrSvz778FSYVSXJ04SK0VxCtE9bk+Rny77TqJLIW4N6JFXzsaj gs0taq2jY+0KrwO3uBkwFxqHV8ul/POa4bWSWzsZXJrAlbjpt/5uEjJRg+menwPQX0fp WRZ1WF0LvzPuIrQ8R6naVO1s8MIExXSWNZ3zCTksp03ytpU8ZmTb0qZOfDO+9SSIFfxE Mf8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtqaMtLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si3505458ejf.167.2020.11.23.17.57.15; Mon, 23 Nov 2020 17:57:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtqaMtLQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1732326AbgKWMjo (ORCPT + 99 others); Mon, 23 Nov 2020 07:39:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:52276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732303AbgKWMji (ORCPT ); Mon, 23 Nov 2020 07:39:38 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 28E5D208C3; Mon, 23 Nov 2020 12:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135178; bh=Bg3qSo+bdQLpOLN05PDRqkoaJUVuItEwLSi3G6u1Hus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HtqaMtLQpkHsIMJCeYOe5PHenlYo0Ge+yk81Rtm2Ha66RO695Fh5vSHYgYwlvHrZm 3liD5+g09BYqcDicL3EGt5x48q1lj3bZ4e83iTY38oyEyoWNyX3yVlWEzVW1wO09nI mT3xrirutywtLwkZvjxF4POOtSfMmTxea09kDXY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Han Xu , Mark Brown Subject: [PATCH 5.4 133/158] spi: lpspi: Fix use-after-free on unbind Date: Mon, 23 Nov 2020 13:22:41 +0100 Message-Id: <20201123121826.345481795@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 4def49da620c84a682d9361d6bef0a97eed46fe0 upstream. Normally the last reference on an spi_controller is released by spi_unregister_controller(). In the case of the i.MX lpspi driver, the spi_controller is registered with devm_spi_register_controller(), so spi_unregister_controller() is invoked automatically after the driver has unbound. However the driver already releases the last reference in fsl_lpspi_remove() through a gratuitous call to spi_master_put(), causing a use-after-free when spi_unregister_controller() is subsequently invoked by the devres framework. Fix by dropping the superfluous spi_master_put(). Fixes: 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi") Signed-off-by: Lukas Wunner Cc: # v5.2+ Cc: Han Xu Link: https://lore.kernel.org/r/ab3c0b18bd820501a12c85e440006e09ec0e275f.1604874488.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-fsl-lpspi.c | 3 --- 1 file changed, 3 deletions(-) --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -973,9 +973,6 @@ static int fsl_lpspi_remove(struct platf spi_controller_get_devdata(controller); pm_runtime_disable(fsl_lpspi->dev); - - spi_master_put(controller); - return 0; }