From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E7FC10F13 for ; Mon, 8 Apr 2019 20:09:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68EB42084F for ; Mon, 8 Apr 2019 20:09:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ehTKNzIg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="RHIoBzR/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68EB42084F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k/o2sdGQ7hNQhXKm7DoDF1Bxoh/FVjDghK3nsSxpBfM=; b=ehTKNzIgIhCPm4 bym30IsqEJcp+eRB6SVZCmMjvCCwFRdDAp8ITPzDhwF/fkumlU8NwkBlyVSBvqQpHuOcr25XSB640 t3CFfMLf5KWf3lBcJn2f7LJkF34KRjMrN9M2Dl96adTbvqsOCtE+KOfVl7P0jRXkmd3atqMDQ5kWW YXYoMLOfbTcEoyZqm3HBC8Sp3spVYh6MtrA9OAHpjzz1LjgwDFbTsboai5N6dkGhsYR/J+D2P2BaL zZTT5w+MCvitWu0RlN9gne4dFLBPHQhMPntY0r4nzQj1V2qVcfJ4DNCOT9tEiORev2Y0qqAxhv+cy EE9BWMvKGQFJqJh4OZGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDaa2-0004Qc-CQ; Mon, 08 Apr 2019 20:09:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDaZz-0004Q2-PD for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2019 20:09:21 +0000 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 47BDC2084F for ; Mon, 8 Apr 2019 20:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554754159; bh=ZeEZb1pZ60/ju3r8ey+U+aCL1uve8ZoE5VVj6YTXkKQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RHIoBzR/hmqXIub0rFs7OZZiZtzWbEh3HQiZfESsS90nalNFm2skb761XEBDUPego 52dihXSVbbZghkSZZ0BtzaKJlqZoPDndfZGco1xyQjxn1/4WZJyhLoPr6UvmCBm/mg z/C5aly7A2m9qv9ZxKc6k91/gbFEyeszD+6QF7t0= Received: by mail-qk1-f176.google.com with SMTP id k189so8855694qkc.0 for ; Mon, 08 Apr 2019 13:09:19 -0700 (PDT) X-Gm-Message-State: APjAAAVE6DcW5XC7nvKGNbcZraIPzZy1xbTxMgocreU+6k6YFHToomph wjpL3whLf0saxVPxnFoDN09boFaFzq2b1KiO4g== X-Google-Smtp-Source: APXvYqxOjr0OFjB/wBPjDGtGO4BoLY0cK9Ay4jl8gbII/gNM/CbQKHyXwawPyafDOnZV7e2zPTaBCrwB7Clj34gPL/k= X-Received: by 2002:a37:6441:: with SMTP id y62mr24011951qkb.158.1554754158515; Mon, 08 Apr 2019 13:09:18 -0700 (PDT) MIME-Version: 1.0 References: <20190401074730.12241-1-robh@kernel.org> <20190401074730.12241-3-robh@kernel.org> <155412649586.24691.809508732198367112@skylake-alporthouse-com> <8736n120jw.fsf@anholt.net> In-Reply-To: <8736n120jw.fsf@anholt.net> From: Rob Herring Date: Mon, 8 Apr 2019 15:09:06 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/3] drm: Add a drm_gem_objects_lookup helper To: Eric Anholt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_130919_839880_DC7DF36E X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , Maxime Ripard , Sean Paul , Will Deacon , Linux Kernel Mailing List , dri-devel , Chris Wilson , David Airlie , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , Alyssa Rosenzweig , Daniel Vetter , Steven Price , Robin Murphy , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 1, 2019 at 10:43 AM Eric Anholt wrote: > > Chris Wilson writes: > > > Quoting Daniel Vetter (2019-04-01 14:06:48) > >> On Mon, Apr 1, 2019 at 9:47 AM Rob Herring wrote: > >> > +{ > >> > + int i, ret = 0; > >> > + struct drm_gem_object *obj; > >> > + > >> > + spin_lock(&filp->table_lock); > >> > + > >> > + for (i = 0; i < count; i++) { > >> > + /* Check if we currently have a reference on the object */ > >> > + obj = idr_find(&filp->object_idr, handle[i]); > >> > + if (!obj) { > >> > + ret = -ENOENT; > > > > Unwind previous drm_gem_object_get(), the caller has no idea how many > > were processed before the error. > > I had the same thought, but the pattern we have is that you're loading > into a refcounted struct that will free the BOs when you're done, > anyway. The real bug here is if allocation of the array fails. The BO array may be NULL when the count is not. So this V3D cleanup hunk: for (i = 0; i < exec->bo_count; i++) drm_gem_object_put_unlocked(&exec->bo[i]->base.base); kvfree(exec->bo); Needs to be wrapped with 'if (exec->bo)'. We have a similar problem with fence arrays too. Thanks to Steven for noticing this copied code in panfrost. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel