From patchwork Wed Apr 4 10:23:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10322397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 97C1860318 for ; Wed, 4 Apr 2018 10:24:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 912B428E19 for ; Wed, 4 Apr 2018 10:24:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8357928E24; Wed, 4 Apr 2018 10:24:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3745828E19 for ; Wed, 4 Apr 2018 10:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=DtDSlwvasEXZl9wyPNKoghAfZGeAYSEUmtbU9PayjWI=; b=SQF 2jqseHR6Z3lgmQX0hbIJ8FbSA13kmvneEAGmprL5q3e0Bjly5zQ7FivMbeImk+WMbH3sDdisC4H8i uxgoPg/AU0B6XmxN8W8lQ0w+9mw6/YQDvPiOL/HwQ3A7qVg2/9BeKPdp4VxKUIctPYqe/GueeCTXh TwS7dtWb1Pfo6cLvsqgDdlnfCLVThMGaal/Y68LJ58UwlCi1xXHnEYXzV520T3rVUE7hKY26wWzXm XvMf0/7TkRv+mKtm2iWSfbYNJpH//MfCtRH0dFGpiXX0XqMYPrlbrCMyEuDw7mHyDrTxNOSllfFRU TKGEr1r765W4ZyiSQbQCsN3fXIAn4dQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3fak-0005fk-AV; Wed, 04 Apr 2018 10:24:34 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3faf-0005dU-3L; Wed, 04 Apr 2018 10:24:30 +0000 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lr24R-1eZZZ21QXr-00eaM9; Wed, 04 Apr 2018 12:24:03 +0200 From: Arnd Bergmann To: Joerg Roedel , Heiko Stuebner Subject: [PATCH] iommu: rockchip: fix building without CONFIG_OF Date: Wed, 4 Apr 2018 12:23:53 +0200 Message-Id: <20180404102401.3634085-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:7CmUPavO3w1gNayRTTinbvsD5Hwunayj36eLBmr1zHhRH1ejn4w obFJth4IhGTL7uSaBD8/qipw+71XqPckzNnJdpNvqi15Zr0Dg+xXAnh/7GzOvAvkaryWnho FCWG/f6FReptov5LiQVDo9bW3+KDhQZMu8KKdrYfTx17dhRQ53rPoU+XpZ/54b6Oou9TVLS k8yDjPTxB4W1nsStolNdQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZWoxCgApfZk=:aRqQG8UVibrgDW9/KcBJUZ i4ROiA1cWmNvCgui6/RDAtsi1ULIBOY5Y8ueW8qgGmDw8UueSE+MgAxfWgZAS42LJtSQAwVJT SwqnL1GBYlh6XyCNdFC38wKQxXoBaflhDSewJgYl9bv+Jzew0xase0aK3uzHLrBOwYdOP9R00 liVNcIUVRPvNWd5uTrBAzfG2gxqANqG5TTkqRmi0dg263260ytuntVFfEJGK7FcRuCxdNsizu hBVZBY3KE+Iy+690qR1bgvIROTcV+3B95Ja76017fFBye8M3474fBFzT5uvVmCwcjQWw/BWSf DEpBVKdGZS7ChXbfDKXPuEsbLh+MZyT1r7OkwrCPgMpRp4tYSupXd1dYQgxqSw8aoJN/hNJTX Dx0O+FeyGoswyt5wJ9zU96tiFJrB/b23ncQdE/o5yZt9/wG2ynACov5meyPU2dFf6JDHCXvmG M9Pduu0LraX1GTSXRxwcRlx1P6uPURlQY6ddOMzSojofNrkJe4BC4ZhhZ3Xp42NxeShovJlgl y/jH5YzQfeEmFB5wfHtpmO4shjZucvNOF/zNYJf231W9XGrTrdfrGwEb4WJ4cZjp16JheHwRX tfgiSx14nz9+WZxT4CovQNEruhtGL5BzzpWkx01QLgyXeb+QwUwpjWorc47700+S/CWYG4nuF fvcYA3GxJsa5Ee89VZmuqIrhk7twsRRLJuFy2RNO/5koIXWWAvNTwiN0Chq/yNiWCrsxT/kaw AkPrcxiuoFLp68xPDiEhOkKT+Bi+NB1q2r+EXA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180404_032429_455890_C1D9FA93 X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Xue , Arnd Bergmann , Marc Zyngier , Jeffy Chen , linux-kernel@vger.kernel.org, Tomasz Figa , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Robin Murphy , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We get a build error when compiling the iommu driver without CONFIG_OF: drivers/iommu/rockchip-iommu.c: In function 'rk_iommu_of_xlate': drivers/iommu/rockchip-iommu.c:1101:2: error: implicit declaration of function 'of_dev_put'; did you mean 'of_node_put'? [-Werror=implicit-function-declaration] This replaces the of_dev_put() with the equivalent platform_device_put(), and adds an error check for of_find_device_by_node() returning NULL, which seems to be appropriate here given that we pass the device into platform_get_drvdata() next, and that of_find_device_by_node() might theoretically return a NULL pointer. Fixes: 5fd577c3eac3 ("iommu/rockchip: Use OF_IOMMU to attach devices automatically") Signed-off-by: Arnd Bergmann --- This warning appears to only have been introduced in linux-next after the merge window opened. --- drivers/iommu/rockchip-iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 5fc8656c60f9..fe9c9cc1a9d4 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1094,11 +1094,15 @@ static int rk_iommu_of_xlate(struct device *dev, return -ENOMEM; iommu_dev = of_find_device_by_node(args->np); + if (!iommu_dev) { + kfree(data); + return -ENODEV; + } data->iommu = platform_get_drvdata(iommu_dev); dev->archdata.iommu = data; - of_dev_put(iommu_dev); + platform_device_put(iommu_dev); return 0; }