From patchwork Fri Oct 21 17:12:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Anholt X-Patchwork-Id: 78698 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1406906qge; Fri, 21 Oct 2016 10:12:58 -0700 (PDT) X-Received: by 10.107.44.3 with SMTP id s3mr2077595ios.236.1477069978650; Fri, 21 Oct 2016 10:12:58 -0700 (PDT) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id f1si2882915paa.160.2016.10.21.10.12.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2016 10:12:58 -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; 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 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA2826E08D; Fri, 21 Oct 2016 17:12:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from anholt.net (anholt.net [50.246.234.109]) by gabe.freedesktop.org (Postfix) with ESMTP id B6CEE6E08D for ; Fri, 21 Oct 2016 17:12:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id D5D152C9C06D; Fri, 21 Oct 2016 10:12:42 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qBZiwJqe04q5; Fri, 21 Oct 2016 10:12:40 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id B616E2C9C06E; Fri, 21 Oct 2016 10:12:40 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 5799B2E6E09; Fri, 21 Oct 2016 10:12:40 -0700 (PDT) From: Eric Anholt To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/2] Return an -ENODEV from drmGetDevice() when no device was found. Date: Fri, 21 Oct 2016 10:12:39 -0700 Message-Id: <20161021171240.6972-1-eric@anholt.net> X-Mailer: git-send-email 2.9.3 Cc: linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Herring Fixes crashes in Mesa on platform device, which expected *device to have a device when 0 was returned. (code from a paste by Rob, commit message by anholt) Signed-off-by: Eric Anholt Reviewed-by: Alex Deucher --- xf86drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xf86drm.c b/xf86drm.c index 9cfca49ddfda..9b52889e4cef 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3181,6 +3181,8 @@ int drmGetDevice(int fd, drmDevicePtr *device) closedir(sysdir); free(local_devices); + if (*device == NULL) + return -ENODEV; return 0; free_devices: