Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3193047yba; Mon, 8 Apr 2019 13:10:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQCReE6K91sUEr13njsyADzAiOKsMKvZFXzl/4BQUsDMy0KYcgyi/RQibyiAly+uOhoxpb X-Received: by 2002:a63:84c7:: with SMTP id k190mr29762305pgd.255.1554754218680; Mon, 08 Apr 2019 13:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554754218; cv=none; d=google.com; s=arc-20160816; b=Wh1r1jqnrPCFGOHZ6Y8ZTJ96NP2n7iNbIplPTvu3FY/15K6v0hMlAE5cNHe12G7f1t A2zTObQxX6c1HmrMVf2tU2gIFI7alqEBrw3HE1G3vS+ca9YS6s5Gslt/hATlIkHmXNzZ g52YsAxO/TqsCiwv64hmlpglf/xziS19zZDVI5ZbrsQ3FLrBRsWMKhGzdTH+5Zo2DgjP So4/lmSo+eXubqWsOidqkJNp/tdCrGsSCjzDoNJoH8TnlIritHW0l10yLL6ZV9iQYq9o /paMYKPAXZGhd9RIryqSxaLBqlV3nIWvO37xRGZkMiZcE8vWr1WAWofc9imkjpmSCrgO a57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1W89vWBBxvh+YhFdqt0ZHf3VTlskReow9LkUieXs6XY=; b=ttta0Axi5r8ITn+po6JzV9Yw4ZZmd/peca63vYqZt5EuoOpy8AMWVwToVaaO7goZnx mzP2X8Cqj7fcSjsutgdERbKe9BHooc+D5FGkT78zvx5PyA5hIzJd6LLB3iO6FsrsVPJh OueX/BaMJQdBpTY+wcwTIzir0nt1DOIRftb9l5j6B6VizM2Mv6xrRl4kDi26vgXxqO+R ljx7xkinj5u9pLyRYSKcOIzHZrmcX+FuMcyTxaOEnge5LFQR4VpSPoV83qQbFZIxy59V lsNk0X0ybYTocT0d+T0kbxYwl1QqIbR+eTeD0nYuNmRSUw4LKgNu2+rjd6t5gHVM8YWs sDcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RHIoBzR/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si27307392pgh.139.2019.04.08.13.10.02; Mon, 08 Apr 2019 13:10:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b="RHIoBzR/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbfDHUJU (ORCPT + 99 others); Mon, 8 Apr 2019 16:09:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:59116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbfDHUJU (ORCPT ); Mon, 8 Apr 2019 16:09:20 -0400 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 5586421841 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-f182.google.com with SMTP id y5so8812146qkc.11 for ; Mon, 08 Apr 2019 13:09:19 -0700 (PDT) X-Gm-Message-State: APjAAAXpPjEn97eVJ8Pr+1mio1giVfl1IRUk9VScLUHAIxQZjZmFxAxK gnH3VMYLSD0NJHLZX6NKZvZ4f4bT4gYW+PbF5Q== 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 Cc: Chris Wilson , Daniel Vetter , Neil Armstrong , Maxime Ripard , Robin Murphy , Will Deacon , Linux Kernel Mailing List , dri-devel , David Airlie , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux ARM , Sean Paul , Alyssa Rosenzweig , Steven Price Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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