From patchwork Tue Jul 14 14:10:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6787521 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1632C05AD for ; Tue, 14 Jul 2015 14:06:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C4922055D for ; Tue, 14 Jul 2015 14:06:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 685C820709 for ; Tue, 14 Jul 2015 14:06:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 359DB6EA28; Tue, 14 Jul 2015 07:06:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6DB46EA27 for ; Tue, 14 Jul 2015 07:06:04 -0700 (PDT) Received: by wgmn9 with SMTP id n9so9807411wgm.0 for ; Tue, 14 Jul 2015 07:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DQl5Py5/LNmRW7yKrLBVY1XPKRCxLBLzaRzF1lZnplI=; b=Kx3QIPd36wPMzIVSAoGZKcN3qOnCn/l9zRvmwm6l2LI3zjEz3mixaAJoMO9tq54ucn t0NCdkoiQJ+YUtZ6/TMyj4hT+yepsGiEj+hK+cxByv6TWptPJB3AVrsQ2NNApqb9qbUt yDQ5LrCQXBXX/JVTNfRwcpeSGeobaUAz9Ig18Gfs24mBOEKK7dOCTEpdfB6Oc1bvXQdA 70Ief84DTEAxjyOurIlC0lKdK0fkPUrV8OwAWhVFKfG/fI5raOsKD2WHgQdWqR+jBtV3 W8775fxsUaZcT7t7J2z7hdh7dVPRQzIHYs5vUQh2I4qWVFo5bEu6/3IKPl0uGh72+sJE 4jpw== X-Received: by 10.180.84.194 with SMTP id b2mr32256254wiz.36.1436882763216; Tue, 14 Jul 2015 07:06:03 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by smtp.gmail.com with ESMTPSA id fb3sm20979888wib.21.2015.07.14.07.06.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 07:06:02 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 3/4] xf86drm: fix incorrect fd comparison in drmOpenOnce{, WithType} Date: Tue, 14 Jul 2015 15:10:04 +0100 Message-Id: <1436883005-6163-3-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1436883005-6163-1-git-send-email-emil.l.velikov@gmail.com> References: <1436883005-6163-1-git-send-email-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com 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" X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Spotted by looking for similar "let's assume fd == 0 is invalid" bugs. Cc: Thierry Reding Signed-off-by: Emil Velikov Reviewed-by: Thierry Reding --- xf86drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xf86drm.c b/xf86drm.c index 2c17d11..39c6e2d 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2619,7 +2619,7 @@ int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type) } fd = drmOpenWithType(NULL, BusID, type); - if (fd <= 0 || nr_fds == DRM_MAX_FDS) + if (fd < 0 || nr_fds == DRM_MAX_FDS) return fd; connection[nr_fds].BusID = strdup(BusID);