Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9097318pxu; Mon, 28 Dec 2020 06:34:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRJwkb7iaJnM/5zi4HD0+2LcYEP8puLTU8GCt1i3oyyieSkBEr+rZVE5I40oGB611Az9gk X-Received: by 2002:a17:906:2798:: with SMTP id j24mr41810313ejc.328.1609166063734; Mon, 28 Dec 2020 06:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166063; cv=none; d=google.com; s=arc-20160816; b=sPqEUfZB43jlvu6A/pT1sAgFXH1IeqOIEssqmnAD6nPE0w6OL2OlmTyfQxjOmbg38R QtGvxqu1g9035RY0R4RROauAPgNFvPUzTAMNAv4yPJXku+kHYSvufMSy7h2Bcz7qcdrj PJtuv1bxbBSjvQ9YQ0WDCqmmpfelfGz+4qEaZuc9zPHSo3C4hLTZJ6T+qWhlvqqCuBnx Da/q2a1SPCEm4z9vLxq5MollT+0x/HRroH3RUFKYvOhGgVaFiHbOO++3OnRo9ykipRhY v2ckh3Dn7F/AO7iCX/Y87b9DMOS0qLrxx9cfHrwPxqGQLKb9SdglVpjcngjTU4oACfSW fKrQ== 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=rwdcDVdBwNzGvZTgZexriZkj0oye5Aboov6lvxneUVo=; b=q4JoJ4EkFrtZtsrA0rRwQkrSUoMIsTrnRC/hR+mX93FO6qIRS40yjWYa8J0PO1BL9I H7wTSvAIhuCni5TJMj9LtKAugPUSngTf1Tg4B/Y9iOe0HKMQtmFY4Gk+96NAXueFSDg1 PjeIscELAJbWqkqlwdawEyxCpCFODMqrlb5rbzD51SX+w4wTD7aeiVWJ0Ut0mhDMunVR 40TtU+ImAKzkrbLveydzPbUeyp6HebAOlwa/eKWoZzwPcFLQ+w8CbL6UyBLVEp9DFsCg aDCKeF1ZuRolsbXL52JOZPRUX5qo3r+dxJKipffvgxt0rFGagcMouTbF/r2eOl7aODjv dC6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+LfA2Ic; 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 cx27si16057404edb.264.2020.12.28.06.34.01; Mon, 28 Dec 2020 06:34:23 -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=u+LfA2Ic; 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 S2504642AbgL1OcQ (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:39282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504359AbgL1ObW (ORCPT ); Mon, 28 Dec 2020 09:31:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D300920731; Mon, 28 Dec 2020 14:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165866; bh=87RGqwbipPsHoe8KTxCUzb+H8t2y4Ndb8/ky8BPf+zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+LfA2IcGNKbAfqJokZ+7ZCaHBKG9FVi4nw/mTo76IH5RIZSUPjDh8pSGCopXX7jQ PBCWtE/3qDBdzkMWR9yBQUt1R9Qg4pknULxkD3jDemnU5FyZpljGpT9yAHhzGwjELR Jl5Ab0viS/almd2UUZIpomHdoOkmmyoBGRg0/j1E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Mark Brown Subject: [PATCH 5.10 641/717] spi: pxa2xx: Fix use-after-free on unbind Date: Mon, 28 Dec 2020 13:50:39 +0100 Message-Id: <20201228125051.641238521@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-pxa2xx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1686,9 +1686,9 @@ static int pxa2xx_spi_probe(struct platf } if (platform_info->is_slave) - controller = spi_alloc_slave(dev, sizeof(struct driver_data)); + controller = devm_spi_alloc_slave(dev, sizeof(*drv_data)); else - controller = spi_alloc_master(dev, sizeof(struct driver_data)); + controller = devm_spi_alloc_master(dev, sizeof(*drv_data)); if (!controller) { dev_err(&pdev->dev, "cannot alloc spi_controller\n"); @@ -1911,7 +1911,6 @@ out_error_dma_irq_alloc: free_irq(ssp->irq, drv_data); out_error_controller_alloc: - spi_controller_put(controller); pxa_ssp_free(ssp); return status; }