Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp26151pxb; Fri, 15 Jan 2021 05:02:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLRM+85jpasvzXPiPmFUfP/gxxaqlv0rIA+QluwFxQiB/MP7y7bqqY0y70cEy2yTngqbtx X-Received: by 2002:aa7:c64e:: with SMTP id z14mr9659309edr.69.1610715758295; Fri, 15 Jan 2021 05:02:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715758; cv=none; d=google.com; s=arc-20160816; b=ioPjU/f5MP6THAzyJ/h22tc6d5SVHqyDuva8XSSxBWA5eDz28ehVonkYIVuMBrHS9Q 5i4T1KznpbDexv7ltwbPUIEqB+cRYHA4rkh72e/M4IT6tMVlnSYYhhvHtqBX2tggWVap uQ5rQc9c2wLxRrsloKkQLaiTorB06w2e/F81mtfityPwmQ7jC095sdBbyvImyUt2n0yI aCIbyCBPT+mrwKO6N3nqaRFlFe+1lqcJV8kpjqKkwwQi7jVyuaCNWodUe+IgF2icKcB8 6KLkEP3dCQzkJKDE5VbJ6dVKcnBAo1W1FzsXBF+8Um/K4tHsuDFQbw3DqwzFPYD6H6op Dw+w== 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=UwN+6wwaEWDECCkH/thnHOFvAXH9XEHk1VXXkXgITNY=; b=fMGtrisId8tNd497+1NLbJfyRml97s1I2cZf4XoQg5iFlCOdoyug3evAlAyxYVCw2j FMyyKb44P4ziHtry0xsljYa6p964q3S23MgA+DPtZ6+NwJW3Fyh03xMDrr1/mLETK2Ut hEYFylk+OSdbkntu6bDRpEN7u2znBrmfoesrMId416PA8SQaotU5Y14kAEePGSxw1RSB JTsgbEdGuK4hYbEd/+2J/4UuuCwJI2VQ81VzO+73AuyLMimSxWBd4izqSgth5/EFS7BK CiaZGoo01P8RG9jB5HyRgyD3j/7YNtzOiU0MDqdww7ZqV0nq0HxPeuXIwHk79LJhcCLG 7rvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XiKHHE+A; 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 y25si3880165edi.528.2021.01.15.05.02.14; Fri, 15 Jan 2021 05:02:38 -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=XiKHHE+A; 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 S2387806AbhAONBL (ORCPT + 99 others); Fri, 15 Jan 2021 08:01:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:40006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733058AbhAOMdI (ORCPT ); Fri, 15 Jan 2021 07:33:08 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF87622473; Fri, 15 Jan 2021 12:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610713947; bh=0D2WU/KUDq2zpa4vQ6R8y1QVPUQDtfr46/x/T/HDcW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiKHHE+AjQ+EfAgIgpXdO9tV0c/tjVEK/j8FIoIF0duhSvhKRuybGpllWveClAWj7 dv60U90P+yYd2LKTW6exm6Lbmgm9CJDMq4otfhXaAvtPxTd+me+60V/1UBvz3lXdzA MuuHJ013YvhKDCBkwJmtCjIjqa9zLxHc+tYf99uY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Mark Brown , Sudip Mukherjee Subject: [PATCH 4.19 20/43] spi: pxa2xx: Fix use-after-free on unbind Date: Fri, 15 Jan 2021 13:27:50 +0100 Message-Id: <20210115121958.030492373@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121957.037407908@linuxfoundation.org> References: <20210115121957.037407908@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 5626308bb94d9f930aa5f7c77327df4c6daa7759 upstream pxa2xx_spi_remove() accesses the driver's private data after calling spi_unregister_controller() even though that function releases the last reference on the spi_controller and thereby frees the private data. Fix by switching over to the new devm_spi_alloc_master/slave() helper which keeps the private data accessible until the driver has unbound. Fixes: 32e5b57232c0 ("spi: pxa2xx: Fix controller unregister order") Signed-off-by: Lukas Wunner Cc: # v2.6.17+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation Cc: # v2.6.17+: 32e5b57232c0: spi: pxa2xx: Fix controller unregister order Cc: # v2.6.17+ Link: https://lore.kernel.org/r/5764b04d4a6e43069ebb7808f64c2f774ac6f193.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown [sudip: adjust context] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-pxa2xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1572,7 +1572,7 @@ static int pxa2xx_spi_probe(struct platf return -ENODEV; } - master = spi_alloc_master(dev, sizeof(struct driver_data)); + master = devm_spi_alloc_master(dev, sizeof(*drv_data)); if (!master) { dev_err(&pdev->dev, "cannot alloc spi_master\n"); pxa_ssp_free(ssp); @@ -1759,7 +1759,6 @@ out_error_dma_irq_alloc: free_irq(ssp->irq, drv_data); out_error_master_alloc: - spi_controller_put(master); pxa_ssp_free(ssp); return status; }