From patchwork Fri Oct 16 22:11:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 7421221 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 C2160BEEA4 for ; Fri, 16 Oct 2015 22:12:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09472208D2 for ; Fri, 16 Oct 2015 22:12:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2E23F20638 for ; Fri, 16 Oct 2015 22:12:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 556076E13A; Fri, 16 Oct 2015 15:12:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 379C56E13A for ; Fri, 16 Oct 2015 15:12:05 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 16 Oct 2015 15:12:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,690,1437462000"; d="scan'208";a="828866725" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by fmsmga002.fm.intel.com with ESMTP; 16 Oct 2015 15:12:04 -0700 Received: from mattrope by mdroper-hswdev with local (Exim 4.84) (envelope-from ) id 1ZnDEK-0005V6-QK; Fri, 16 Oct 2015 15:12:04 -0700 From: Matt Roper To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/2] xf86drm: Handle unrecognized subsystems safely in drmGetDevice[s]() Date: Fri, 16 Oct 2015 15:11:24 -0700 Message-Id: <1445033484-21089-2-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445033484-21089-1-git-send-email-matthew.d.roper@intel.com> References: <1445033484-21089-1-git-send-email-matthew.d.roper@intel.com> Cc: Emil Velikov 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Both drmGetDevice() and drmGetDevices() currently print a warning when they encounter an unknown (non-PCI) subsystem type for a device node, but they still proceed to assume that the drmDevicePtr was initialized and try to add it to the local device array. Add a 'continue' to the error case handling to bypass the rest of the processing for devices we can't handle. Cc: Emil Velikov Signed-off-by: Matt Roper Reviewed-by: Alex Deucher Reviewed-by: Emil Velikov --- xf86drm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 951edbb..7e28b4f 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3140,7 +3140,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) break; default: fprintf(stderr, "The subsystem type is not supported yet\n"); - break; + continue; } if (i >= max_count) { @@ -3244,7 +3244,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) break; default: fprintf(stderr, "The subsystem type is not supported yet\n"); - break; + continue; } if (i >= max_count) {