Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp492283imm; Sat, 14 Jul 2018 05:38:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfC75+lFbJ0HgARjWyCNJBg5ZIQ9mXbSN74vB0PHTVc+HXvXH4dknhU9pIAjY1Pgj8aIAWy X-Received: by 2002:a17:902:184:: with SMTP id b4-v6mr10166349plb.340.1531571894334; Sat, 14 Jul 2018 05:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531571894; cv=none; d=google.com; s=arc-20160816; b=aMgXW/6tCVELE35ngTHbOtw8ijfAr7SfnPQ/1peG/Ufo/lszS8NzAXlJcejWKoSi3F Jghdcg2erX3IqLGlPVctyXCuzIEV+a3c6dyP3mVe4TIKCOILp30kLwhUnk/QnvbSxDIu /1RHgZozxdITTWUh3o/Vj7v0QrmXdV4ilSlUJd0vEUn8djj6IpXJ/pS/b1LMuvyUCzq7 fQWmAAsbjgfdrldKSyJ8SiH6EMk2ZCl8gwEa5BapMLaBfyPesnhyhUsbgoBMBSO62UUz bBhg9RLtra/3SFtVk14hguzsbfOI7wb4iq3QbIglIp9LlDA05DWsM+6y4v7GeGptYQXk yCoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7OGYnxntBC6F9GrwairXrX1t2U41YhxH0WTSQOTePlQ=; b=ZbHewyE6V0mo3RpL+2RNfWq/06PPWFiVlddDfh8RLnQtnh+gHL4RdJl6cl6EevGlX0 5NJ8ZGaLMYy+0rtli5jZYFAkbP+QKwZNy2V3vv/bvr/NxuTam9sZse9S7oi6t0f8pOPT sTX+rESfNVJpPM5sdCa+nU6g2Fz9IplO9U9ZQgj/B3AlNQDNRxgxMUUBwqGGsLj7Bj6a AMHKyjNIca+dMUHNoNjLIMhNA2HWzeOAoddLiMWZmyy5IY0xmXCheOuCFOsFtRhaRy3C PpbVw4FrJbiUBoIVcHFHduig4koGJagSwSB/c9uLAjqKvZtY6lOH/fIAkm7nXWrDZNTd mE2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si24953813pga.298.2018.07.14.05.37.58; Sat, 14 Jul 2018 05:38:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726793AbeGNM4U (ORCPT + 99 others); Sat, 14 Jul 2018 08:56:20 -0400 Received: from www.osadl.org ([62.245.132.105]:36844 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbeGNM4U (ORCPT ); Sat, 14 Jul 2018 08:56:20 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w6ECWu8X023927; Sat, 14 Jul 2018 14:32:56 +0200 From: Nicholas Mc Guire To: Gustavo Padovan Cc: Maarten Lankhorst , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] drm: re-enable error handling Date: Sat, 14 Jul 2018 14:32:12 +0200 Message-Id: <1531571532-22733-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org drm_legacy_ctxbitmap_next() returns idr_alloc() which can return -ENOMEM, -EINVAL or -ENOSPC none of which are -1 . but the call sites of drm_legacy_ctxbitmap_next() seem to be assuming that the error case would be -1 (original return of drm_ctxbitmap_next() prior to 2.6.23 was actually -1). Thus reenable error handling by checking for < 0. Signed-off-by: Nicholas Mc Guire Fixes: 62968144e673 ("drm: convert drm context code to use Linux idr") --- Problem located with experimental coccinelle script The noted Fixes tag is one of the commits that removed the -1 return value in 2.6.23 in drm_ctxbitmap_next() but thats not the only change that must have taken place to invalidate the error check. Patch was compile tested with: x86_64_defconfig Patch is against 4.18-rc4 (localversion-next is next-20180713) drivers/gpu/drm/drm_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c index 3c4000f..f973d28 100644 --- a/drivers/gpu/drm/drm_context.c +++ b/drivers/gpu/drm/drm_context.c @@ -372,7 +372,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data, ctx->handle = drm_legacy_ctxbitmap_next(dev); } DRM_DEBUG("%d\n", ctx->handle); - if (ctx->handle == -1) { + if (ctx->handle < 0) { DRM_DEBUG("Not enough free contexts.\n"); /* Should this return -EBUSY instead? */ return -ENOMEM; -- 2.1.4