From patchwork Mon Jun 25 17:36:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10487081 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 4528660230 for ; Mon, 25 Jun 2018 17:38:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BC9D20182 for ; Mon, 25 Jun 2018 17:38:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DDF922362; Mon, 25 Jun 2018 17:38:31 +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=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC71420182 for ; Mon, 25 Jun 2018 17:38:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1159C6E36B; Mon, 25 Jun 2018 17:38:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x236.google.com (mail-wr0-x236.google.com [IPv6:2a00:1450:400c:c0c::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 715E06E369 for ; Mon, 25 Jun 2018 17:38:27 +0000 (UTC) Received: by mail-wr0-x236.google.com with SMTP id p12-v6so12890577wrn.11 for ; Mon, 25 Jun 2018 10:38:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3NZnWyvAAvxqzWCJKomXkwoRbM4DoqqFXKESS+lMvGY=; b=U1QYSuNpa227Xtyan4nOsGJc8Q+sQwgnPEAPsc1+pvVNu3DkMR9o5HJsr3KN0nzvy/ fUKbhy22z1NEJlMRYPgNiIhuOS0qOmE4vJwrPpzaYA/doRmqFvlG9o/T8qJSrjaAQwsr mJ/Rh12m/Lo6OXW2GqV+bh9qg1BSAKEtbgKiav0hibihkoDJS50ZOFGeZmJHTxEHC5xf KiEkFAzWtigERqZN+WhMwWIRXMgjlBHAbArMO4H8oOkHaVN+zjfeXtbTs0blVR90GWjv PMdtzrx1ooIeUhY+6NK+U3lTjR2lsVtkAJszBYISlzLkbDcD2wUvmS1C929Y+ikOT8hK 7BXg== X-Gm-Message-State: APt69E2EAmJA0/LKCKaV/pOWto4AUPS5WDwID7f2GwwJ5hEmKeG33T6F lXEfXjydHzTbwAPdmj6lSvzqZA== X-Google-Smtp-Source: AAOMgpczWRuOfhcOP/nj1khFasm+iaAK/+kIiCRQxGDLfMFOjPj5GKBgk1+RothUSD3xI9z0fUIPjg== X-Received: by 2002:adf:de08:: with SMTP id b8-v6mr10747066wrm.39.1529948305974; Mon, 25 Jun 2018 10:38:25 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id p8-v6sm6581019wrq.70.2018.06.25.10.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 10:38:25 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 01/10] xf86drm: drmGetDevice2: error out if the fd has unknown subsys Date: Mon, 25 Jun 2018 18:36:17 +0100 Message-Id: <20180625173626.8046-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.18.0 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: emil.l.velikov@gmail.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Currently one can open() any /dev node. If it's unknown drmParseSubsystemType() will return an error. Track that and bail as needed. Signed-off-by: Emil Velikov Tested-by: Robert Foss --- xf86drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xf86drm.c b/xf86drm.c index 87c216cf..e1bbbe99 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3814,6 +3814,8 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device) return -EINVAL; subsystem_type = drmParseSubsystemType(maj, min); + if (subsystem_type < 0) + return subsystem_type; local_devices = calloc(max_count, sizeof(drmDevicePtr)); if (local_devices == NULL)