Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1088546imm; Wed, 25 Jul 2018 11:16:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdwtTYWIKVAoQWFjgd531JGoigIsw/8n3BEwmQ55aUMjia2m/mrBcF79M3rouruN4IrYtZA X-Received: by 2002:a63:4450:: with SMTP id t16-v6mr21559032pgk.102.1532542586642; Wed, 25 Jul 2018 11:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532542586; cv=none; d=google.com; s=arc-20160816; b=opunV6u8xhLQH5ZfFcIb/N8Eyhr1CGffw5mn26d41fYFFiG13HReVhZme3SCqF506j KcxKxBAz5ZmJxhofzWJLzOfyhRbXuc1G50F+dZddIyx8vPErlITqK5NB4ZwiVssfvz07 lN8NZysSpxBfvmdyhN1+FqJKPPqhoqnbpsK1dnsU0KK0iD5cGiYxjcCp4oIgnncyztmq Vkld6TUIrCoD/HFYoJY/sxVUxIedSWhyU4/HFONTotiT5595Z6VsLkDDvv8/5xGN7cMY xZIr+K3twAhcl/mEI2dI4EVkOBHhYvTv7Z3klS3ktkNbrjTS1SPgRWc14GkGzgezKDbn m92A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dia7VGpc7qbyGZK1+6klJMo85hz3Y5lg6tTTHCYgOC4=; b=RmQ6K7xVB1Sk2AMJyKWXJJJs/2G5jY33FPkwvZ8IEnrp6b52xSPnfDDAfpnFOdfk2l QAl8mpYpvzTkN6Bunkw/DsHObKGcAmLpRg6bbxWCYBTaKsKmxKOhf6LTVqsSzwZuV45S hdsnFGtFz2/+yahoCWZ49rhr9JmZ3VQ8PmIqksJGdoCIeIYWdENT9WalsBkQtuSwuvgO PME39ocmH+SmGbu03yJD5wUuG2IZvhtC5caevzozcyU4k+BW5V/vHSZ7OdeeIDQZIC4P oqAmNhHhmcxvTQOpFMtqORFPG6JI/qlIPyMJGygMMjlwJE78jA0iFX+2nS+9L2+6dMy6 ZTSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iutxEYln; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10-v6si14952495pfk.162.2018.07.25.11.16.11; Wed, 25 Jul 2018 11:16:26 -0700 (PDT) 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=iutxEYln; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730166AbeGYT2I (ORCPT + 99 others); Wed, 25 Jul 2018 15:28:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:46278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729367AbeGYT2I (ORCPT ); Wed, 25 Jul 2018 15:28:08 -0400 Received: from localhost.localdomain (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8E5D220893; Wed, 25 Jul 2018 18:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532542519; bh=2rsjs1XTo17y7tXZ7z32CB+LMIjxYQA3SyqO+W/tAMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iutxEYlnkRlXb+z7Skgz1epL5/wSWQWoAt69OjUFV1DOIsuuofHs8rB8YBBXWfsdy quo3LIHNohs2sQYCZ1Ai65/GUpDGZzOuxElxuN20cDGzK8bPKX9ZryJFGOruZXaUK9 INM1E/Ns0Mu69DuEWsX4k/SaBu0Rbn0LfcrSsdI4= From: Alan Tull To: Moritz Fischer Cc: Alan Tull , Florian Fainelli , Federico Vaga , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH 2/2] fpga: do not access region struct after fpga_region_unregister Date: Wed, 25 Jul 2018 13:15:14 -0500 Message-Id: <20180725181514.3501-2-atull@kernel.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180725181514.3501-1-atull@kernel.org> References: <20180725181514.3501-1-atull@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The FPGA region class's dev_release handles freeing the struct fpga_region when fpga_region_unregister() unregisters the device. A couple drivers were accessing the region struct after it had been freed. Save off the pointer to the mgr before the region struct gets freed. Signed-off-by: Alan Tull --- drivers/fpga/dfl-fme-region.c | 4 +++- drivers/fpga/of-fpga-region.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c index 0b7e19c..51a5ac2 100644 --- a/drivers/fpga/dfl-fme-region.c +++ b/drivers/fpga/dfl-fme-region.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "dfl-fme-pr.h" @@ -66,9 +67,10 @@ static int fme_region_probe(struct platform_device *pdev) static int fme_region_remove(struct platform_device *pdev) { struct fpga_region *region = dev_get_drvdata(&pdev->dev); + struct fpga_manager *mgr = region->mgr; fpga_region_unregister(region); - fpga_mgr_put(region->mgr); + fpga_mgr_put(mgr); return 0; } diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index 35fabb8..052a134 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -437,9 +437,10 @@ static int of_fpga_region_probe(struct platform_device *pdev) static int of_fpga_region_remove(struct platform_device *pdev) { struct fpga_region *region = platform_get_drvdata(pdev); + struct fpga_manager *mgr = region->mgr; fpga_region_unregister(region); - fpga_mgr_put(region->mgr); + fpga_mgr_put(mgr); return 0; } -- 2.7.4