Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4044946yba; Tue, 9 Apr 2019 09:57:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0QNcZ3Li2/WtlicCv567nihG4y74IcJ+LTu0Zb/IjB9PfkLHlU2/Sl8Pze7KZFEEdXHnu X-Received: by 2002:a63:5c43:: with SMTP id n3mr33234056pgm.163.1554829071521; Tue, 09 Apr 2019 09:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554829071; cv=none; d=google.com; s=arc-20160816; b=Xls0ju9+mcs1Fo7e61Xx8JM5acUcg+Z4+JXkJIyqNaZuR3JOI00/w4CS9teI+pMRaG aN45KPJqwAI943DJOUghfskQOrUAYSKuAWuleUftwjGo88RHFfM+/zc9Iz1Bjh+kc6sy s/p5DbQT79Tb/mFmn6g4p873DrCtt/ObZfwQrVF83XgcRUdRcECScKONC7NjzhqrtVm+ LZ3g6QOhd5sgyBNMWrKzzexuMyXthm06ZSZVu7iIDW/ZukbKhSeOnMhM+cota9RC837i yJTE/UPaD/KpEf54G++pYF9VxK7MgmjIUiI8zhQoXBhb8wVe8M8LCAUaEWa5v5I5zEgR BTtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from; bh=qb1Ag9A0dtCYKcUQtFI9TQmVng7zE4u28e7eq89g4KY=; b=ttbMS2NOlCWwRrxWiR0bAIzPsW6Otjuap74Pm7LnCiDcsW8B3UvDf1Zivv5RAr9YSp klQzZF/K5wWy/anqxjwdk7bk67+JDKodanvxCf03DrNXZEza0lTmOgoSQeVX6I0vlfAm 0+fOiuNchBgfaQJXHZS2v6QvATf3KU4mmdGU7wquRSDoRgTkpX1QmnbJVq2TR1bCkuc8 /RUcuQEvy4k7TUhn+68x/bC9DFMmMtfkxu3fPG9c0qE2E0Mx0nj0mmlD7ig7jLw+E5Uy ipWFWpNcNxa17GQBW1NfIFWcalWcjb/FcWhDUjzGstK+bGdxMXiHs2jvwJOilFXgsf7E 2YEw== 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 i27si27542004pgl.305.2019.04.09.09.57.35; Tue, 09 Apr 2019 09:57:51 -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 S1726523AbfDIQzb (ORCPT + 99 others); Tue, 9 Apr 2019 12:55:31 -0400 Received: from anholt.net ([50.246.234.109]:38128 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfDIQza (ORCPT ); Tue, 9 Apr 2019 12:55:30 -0400 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 2E1BE10A32EB; Tue, 9 Apr 2019 09:55:30 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id AP9KTSRNASch; Tue, 9 Apr 2019 09:55:28 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id A1FB210A32EA; Tue, 9 Apr 2019 09:55:28 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 3DC602FE36FA; Tue, 9 Apr 2019 09:55:28 -0700 (PDT) From: Eric Anholt To: Rob Herring 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 Subject: Re: [PATCH v2 2/3] drm: Add a drm_gem_objects_lookup helper In-Reply-To: References: <20190401074730.12241-1-robh@kernel.org> <20190401074730.12241-3-robh@kernel.org> <155412649586.24691.809508732198367112@skylake-alporthouse-com> <8736n120jw.fsf@anholt.net> User-Agent: Notmuch/0.22.2+1~gb0bcfaa (http://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Tue, 09 Apr 2019 09:55:27 -0700 Message-ID: <878swjnmo0.fsf@anholt.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Rob Herring writes: > 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. Yeah, seems legit. Not really going to write new patches when I've got month-old critical patches I can't get acked, though. :/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlyszn8ACgkQtdYpNtH8 nugquA/8DPK4mN09dn/AZq67osFqFl6wN3K0sqmG6JaW+Opu7DkzH10fmUthRfbD +q2HSJATWQbIP04FLmCmOp6AeqfWV7aX8jB39ltn3EHxuFb0qdLyFm/Rp6Tyr+sb yn+GknjYKzO56+SZFoaIJuBcpZKEUjaxhfr85fgJxfR0nR7B2wH3n+IIRf+dFWeO 6hmRFNzENYeaPgQCHkNnYLxXnQDIDZ+eScp1Z3CwpU4LCJFEM6LylXx7xordg9qa ljfYYT/asSruPYpvTjiQ2fhvlsgFizn6uA4R//Ls45LMtQaT/4gnCFuAI8w8559O ppg7QkBHqbUYji7bSZVQzQwp/QNAGwg/aVbaKrLCj1hFRxj73e9VllofndapQV45 Vv/5CYaG84CntgdN8AK34R1s90NHDRkGJV9A3FaY/9sTk1y7uV+OArcdsChhNNRT m4eq1cBGwA4n8ZuxbApcM0m0e6oA6qMxathbeIaTab5UEYnlWl3UTsXaOT0EEuDx A0XRCq1X2natvm9Zf40AX9p4WUDH1eNE7DJyIHO7LY2jC++7v2YwWK2T/ccS09tK QUAhTvQc4wlCBTIz40s7cWcxPmEWQuhcaAnY6e499HZPiE0RoLarMh42t/fiz+Rp Ie3qcv6nRTNQHWJrGCKiKbQEiNK2MSzJxptXA0KGwFcvlp41CcY= =vGS6 -----END PGP SIGNATURE----- --=-=-=--