From patchwork Wed May 2 09:11:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 134823 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp448355lji; Wed, 2 May 2018 02:12:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfTyHrK06vFXZBo3pyguK2jM/D7To8kKSahXkaDdD89ur2Qw6ps9mLsN4xqztkZTToc6qH X-Received: by 2002:a17:902:8692:: with SMTP id g18-v6mr19316193plo.152.1525252340487; Wed, 02 May 2018 02:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525252340; cv=none; d=google.com; s=arc-20160816; b=syOgrYdDKVFPCmL4eG2dLiqWEonBgpeS+Lx2UBCHhgFiPbgsNP8aRBpmHcJtEopxXw KnCgwjWHHrgfug1KeXqe82ntR3cAgyW4VA94v0NcIZxN50WQ8hu6DONEOO62HYynoCCU zN0/W7zjJdKCC8rUwlz7uxh5bbL6A9QLN1wu6Rf9Gjdo7a3A4XNMlsYjA/q/2PxyZj67 ZQZcK8O8i2HEPInMiuz0BdKdMGY6wuJWF2jveDNqXnaqQj8eIgaI0rW8nwgqlfTpr8Fz h4flXpYQbDp050B2fFCMcL8WpQh6IZiR+LkxxpUB76bo8knpqs/RClt8Ui3kSxELCySE HkSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=+X+iquWHrq/9FBgO/HDAdhcGxiVVTQGWbXXfVpOruBs=; b=l+ZSyNkfEzxBimEApl3If6qqtPB2nruTxFiQwtEAwH+242HUApv7EfGH8v+vwcKArz gkmjobF7T+TlnBDnbGKWkokecqOo48DzyAEFS20OiwmAxG78sJ5KJIZZy06/N1CwuPhA ltZ+yshQmo+SK0gLIcPa1KDy7ge7ZUqBekvGZVvHoAWkyQFg8GO39ZMDChrRFNh7jkWk wFKtH4JBQOIxjs7DEmvIQN9UJi3iqxzNr5qdCH1sMkYU/coGbhDGwgvtn3m9RrVZkdB4 qAr3Ep1TJavsFPnu5u1SJMz80hwtraj+qM0uOa9a3/+UNptFPmkYDku+JFbFswU5T1DQ wuzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=Z/u4libF; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id m11-v6si9393729pgs.73.2018.05.02.02.12.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 May 2018 02:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=Z/u4libF; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AEF546E536; Wed, 2 May 2018 09:12:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id D9FAE6E536 for ; Wed, 2 May 2018 09:12:12 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w429CACk001708; Wed, 2 May 2018 04:12:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1525252330; bh=wQpEl/A6OcoEztDB+bayoqWS44lRErZ1jmQSGbGMKIQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Z/u4libFagBFyXUhEpy52XzIEOq48o27wE0EdAeGklrFsVcOxT+prDRhliJKMIJaU KV6acNSAp2vsMogzSnwsQaWyRD8aByadTcjsb9JmIoRUxeXpBz6X6UPQEPOO3oE5ay zkx6BdLWblqCqBl+BaTRnnQ5vFTlUximHvIv1S0c= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w429C9Th002504; Wed, 2 May 2018 04:12:09 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 2 May 2018 04:12:09 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 2 May 2018 04:12:09 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w429C3GJ015655; Wed, 2 May 2018 04:12:08 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCH 4/4] drm/omap: handle alloc failures in omap_connector Date: Wed, 2 May 2018 12:11:59 +0300 Message-ID: <20180502091159.7071-5-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180502091159.7071-1-tomi.valkeinen@ti.com> References: <20180502091159.7071-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Handle memory allocation failures in omap_connector to avoid NULL derefs. Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_connector.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index a0d7b1d905e8..5cde26ac937b 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -121,6 +121,9 @@ static int omap_connector_get_modes(struct drm_connector *connector) if (dssdrv->read_edid) { void *edid = kzalloc(MAX_EDID, GFP_KERNEL); + if (!edid) + return 0; + if ((dssdrv->read_edid(dssdev, edid, MAX_EDID) > 0) && drm_edid_is_valid(edid)) { drm_mode_connector_update_edid_property( @@ -139,6 +142,9 @@ static int omap_connector_get_modes(struct drm_connector *connector) struct drm_display_mode *mode = drm_mode_create(dev); struct videomode vm = {0}; + if (!mode) + return 0; + dssdrv->get_timings(dssdev, &vm); drm_display_mode_from_videomode(&vm, mode); @@ -200,6 +206,10 @@ static int omap_connector_mode_valid(struct drm_connector *connector, if (!r) { /* check if vrefresh is still valid */ new_mode = drm_mode_duplicate(dev, mode); + + if (!new_mode) + return MODE_BAD; + new_mode->clock = vm.pixelclock / 1000; new_mode->vrefresh = 0; if (mode->vrefresh == drm_mode_vrefresh(new_mode))