From patchwork Wed Sep 3 23:58:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 4841301 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C33B9F314 for ; Wed, 3 Sep 2014 23:59:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A32DB2020E for ; Wed, 3 Sep 2014 23:59:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A791A2021B for ; Wed, 3 Sep 2014 23:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934355AbaICX7D (ORCPT ); Wed, 3 Sep 2014 19:59:03 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:48596 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932561AbaICX7B (ORCPT ); Wed, 3 Sep 2014 19:59:01 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s83NwqB6012053; Wed, 3 Sep 2014 18:58:52 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s83NwqbW018689; Wed, 3 Sep 2014 18:58:52 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 3 Sep 2014 18:58:52 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s83Nwqdw020949; Wed, 3 Sep 2014 18:58:52 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.71.175]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s83Nwqt28719; Wed, 3 Sep 2014 18:58:52 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: Laurent Pinchart , Florian Vaussard , , , Suman Anna Subject: [PATCH 1/2] iommu/omap: Check for valid archdata in attach_dev Date: Wed, 3 Sep 2014 18:58:31 -0500 Message-ID: <1409788712-10741-2-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1409788712-10741-1-git-send-email-s-anna@ti.com> References: <1409788712-10741-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Any device requiring to be attached to an iommu_domain must have valid archdata containing the necessary iommu information, which is SoC-specific. Add a check in the omap_iommu_attach_dev to make sure that the device has non-NULL archdata before accessing different SoC-specific fields of the archdata. This prevents a NULL pointer dereference on any misconfigured devices. Signed-off-by: Suman Anna Acked-by: Laurent Pinchart --- drivers/iommu/omap-iommu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 02ef0ac..f245d51 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1092,6 +1092,12 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) spin_lock(&omap_domain->lock); + if (!arch_data) { + dev_err(dev, "device doesn't have an associated iommu\n"); + ret = -EINVAL; + goto out; + } + /* only a single device is supported per domain for now */ if (omap_domain->iommu_dev) { dev_err(dev, "iommu domain is already attached\n");