Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1313174pxu; Mon, 23 Nov 2020 18:06:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrm+jgqTKFYRu7Z+L9tPghwrcbsBda/ote7bcVMhQzTlUdFmzmHHYnVXY/XuHBrhjPs4P9 X-Received: by 2002:a17:906:f89a:: with SMTP id lg26mr2267404ejb.294.1606183576609; Mon, 23 Nov 2020 18:06:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183576; cv=none; d=google.com; s=arc-20160816; b=m9K2NtlNslhPlLQJRYMQY9dFD3+n5aZRzFLbWDMd/s7Co8gK7s/BcJxJjCqj3O9zXM YqBAq9Y/Y8PxKg3hWVuXuO2U5lLa5M6ovW47HqDFe5di9Wy9v6iaZQ0zczVEh4L+wKu4 prJ98laXFi9gM6XX4V4TQ/Jw48HUjY/5m9TMhEbA7eRNUWrcf5DJxkGVPYwFWihXxCw1 RblrXBTgw8507YfFDxzGTUhmfFuAMOj9SB7b0VzRmGNrqbqUTCB7ZA38chzaKdQ17yDu 48JLpk33KFY6MPVetqUA4qt9zc7rsVyfXK+GVZIJirWSP4EDoTFJwCLxmENcXLxLtbbx 54Dg== 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=oieDpKivueuuyAevrRZWBkl2XfkctxIim6LgHQBm7vc=; b=d9Y2CWdHZN+HJXYm5RwDp2Nio4g75A/9BJ/fTEHYcs9ZJgY+ynOl1NMLMdUfsMislb /qP/pv0VW7j8A60ig6/lVxAJ66GwpVIOXzTITKYfQu+w58AAfEVNzRlnQDcs/pd+JYHD p88+mu+UucOul8DBoGQjsZPA1zuNoA/6SDkX2rqzGqHPpGqiNaBI3mBcNEPcqEGuwKlg Afb70eUKYAxw8X81AUkKk8XqivQsrvbYG/qaU2aw/H1SrhdU3qnu7vFJUe+OWfgTG/We wnBRqrQ+I2PVYOSBdq5vsX6HLvR3Wm2GodVwgsCOs3lYi4IrsZgaO+KABt/60mfP44/K sVtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/lLzzRz"; 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 o22si7216776ejb.569.2020.11.23.18.05.54; Mon, 23 Nov 2020 18:06:16 -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="r/lLzzRz"; 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 S2388439AbgKWNEy (ORCPT + 99 others); Mon, 23 Nov 2020 08:04:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:35426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387599AbgKWMuz (ORCPT ); Mon, 23 Nov 2020 07:50:55 -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 D40A0204EF; Mon, 23 Nov 2020 12:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135849; bh=RJnnzNFxUZTEiInnUWYcXBbVU3LLpeSmbJbVGTY5LHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/lLzzRz7k2G+e1MRi+wRsD8fSVZflW06mGjLYphpafQeezUGL6qvCI4s0/VFFefD 57S7wDl/9ZYtDtwiqTRKlb2UIib9qmdNIP+HYv3tjwqIchYnLy0zZnLIUUtY5vDyAo JaZO4WMMB2zi5IZJ507jhwrUDiGIY/imFMs0mXtg= 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.9 218/252] spi: lpspi: Fix use-after-free on unbind Date: Mon, 23 Nov 2020 13:22:48 +0100 Message-Id: <20201123121846.095915656@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121835.580259631@linuxfoundation.org> References: <20201123121835.580259631@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 @@ -938,9 +938,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; }