Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2116818lqz; Tue, 2 Apr 2024 07:42:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXijjT1AkKHDAHAX3tXFwyYxRMlKFq3J9dmO1lyJ5sm313MQJlXFn5g8h/IQY9RAz82YlFGsXJsByXuGf85qoMVqTK4aW2uXnXEDLcUyw== X-Google-Smtp-Source: AGHT+IGOAkTwab5EAQDU+JjTcmOXYP9kxfL92/yfURgRPal4zNUNuXwL+RfZEJoU55w5w8ZD4EQS X-Received: by 2002:a05:6a20:958c:b0:1a5:6d13:2afc with SMTP id iu12-20020a056a20958c00b001a56d132afcmr15270709pzb.11.1712068937578; Tue, 02 Apr 2024 07:42:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712068937; cv=pass; d=google.com; s=arc-20160816; b=Z1x1vwLQogc8M9DysN/pME9M309kuaRQhtmr3v73c28nZIOa31Q4TY3lqkVGAXXYPt Tbixy0oi4JHRY9ib8ba06lz3HQpsVKcGCvLWmJbwbwZXoTjKrW1BYLE0kgVqCJoOA1Vx xf9c7g+UdmfvJgQu7cia8H1ZU+pypScFp0vjuwXpOKZCEDaz5LGGDVl74VarYsWUNXaR dhDmbtCvcr2zEukt7DPB/De0MiO0zEQLc0vH0zij7l/eK0IkiTXy7D/XI+icjiL9PW81 jFuRT9zuqwFeqv85MkgVYFNnnZU09/MiH26YZvGL14rXtzlgSHKi37cMzOdeEK0jvYr9 pKWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=9gI/YDZdrLgWqOWJSEnUG+zRmqoPDBn3gQHD6fscYgA=; fh=doUOskS5337dhgx1dx51sqAPxm1/rr5ERDAl4UiOmgM=; b=NvkQfAAa6jPzOHiL2q6F0hmZO84NlstRC8cIN8IYJHRrUfBGG7OpBiLjCTmJpSOxwO YbmUv8w9yOvPiU0SRmu2zjf3L8BaYleY3eNLfEAAh5bN8SFHVR8bMGtHTsWlA2Jv22vZ qJf0SUZSvUOUD1ZXFW3lOQHPpPW0rpHX8Mu2L/akU3ZmbYZrBAocb+MWvxFgm7aoP8TW N9uJgbUWBU9OOvERYzXzHvGiIzyDXs1LbMx04uSkDXAbCtB45WkAt3dmlrJeUQNAg8+9 VzjPm6Zj/AL8moAdq+xO4g7KdUY9UjWK+0m4bcgCNIxQ9KdE1B3JWRU6J/LZXJdeLALw PRCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WEP49vse; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-128167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lm10-20020a056a003c8a00b006eabe1295d1si12032672pfb.348.2024.04.02.07.42.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 07:42:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WEP49vse; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-128167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1363F285518 for ; Tue, 2 Apr 2024 14:41:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF99612C816; Tue, 2 Apr 2024 14:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="WEP49vse" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DDBF135A54; Tue, 2 Apr 2024 14:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712068724; cv=none; b=rLrf1sPht0uWXwqZxUHLsXTYH8jDNIm51Mt0Mf41Ax2X/0lQAtB9n6SmXzBuyNITQ33ImXtzKuSer/aj7qzwKw+eaaMnBtnZDRibyIf0T9PmbYwHl1LAvbAe5Wep74hkQ+aEnvZywwZbd1Tt3vC9ikhel7WDd0DlTspQxHTE71U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712068724; c=relaxed/simple; bh=sHj/53++2/xX04Sgn2wr5OxJN+WvB3bojyOITCVAkvo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t3XDdr61ZM2voLb43ZYrcAglxofLAtrz8ytms5ieYjSZumHXhlfiEhIrskem9MdESWxRRA2BwQvdX0PhAcV6I4QFqrKrhPIUsLQl7Q87O4dKTB6zG8UcgkfnL0oRyk5Vroij9VSShC8euA9mn9ngzBI9nn/WRodHInNCcTj5Ss4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=WEP49vse; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712068720; bh=sHj/53++2/xX04Sgn2wr5OxJN+WvB3bojyOITCVAkvo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WEP49vsezuEq0PQjLFDglFO2Nrg5WDa5A+aKrWa/74sAWrSp2gG6dKwsg5uZ6OrmW wVFaiAYJN961/Db/Fczh7wM6u2dbOqy6Uxuuvs+xuiFJRJH5MlHQ2u6zFpw28+gCkO fM5PI323MgKDzmsJJUa8IOlNdozz6hiA6hYGbHg+DtQUyU4A/hhbkg/B2yb12eYaK3 qrOA9sdpIHeOvcKjBuNrvNzrQunJ7bM57xRYi5FhF5wISyeNEFHU6zJsb2AR+06gr6 gll6kUX8VRYI/nMu0etcW75cf373Cs8ilPv8LvmSJ2Ibon/NKAxTxZqWQTZNnzjmzu /GHsxdBtMtvIg== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 812D13780624; Tue, 2 Apr 2024 14:38:39 +0000 (UTC) Date: Tue, 2 Apr 2024 16:38:38 +0200 From: Boris Brezillon To: Harshit Mogalapalli Cc: Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Heiko Stuebner , Grant Likely , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com Subject: Re: [PATCH v3] drm/panthor: Fix couple of NULL vs IS_ERR() bugs Message-ID: <20240402163838.34003a10@collabora.com> In-Reply-To: <20240402141412.1707949-1-harshit.m.mogalapalli@oracle.com> References: <20240402141412.1707949-1-harshit.m.mogalapalli@oracle.com> Organization: Collabora X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 2 Apr 2024 07:14:11 -0700 Harshit Mogalapalli wrote: > Currently panthor_vm_get_heap_pool() returns both ERR_PTR() and > NULL(when create is false and if there is no poool attached to the ^ pool > VM) > - Change the function to return error pointers, when pool is > NULL return -ENOENT > - Also handle the callers to check for IS_ERR() on failure. > > Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block") I would explain that the code was correct, but the documentation didn't match the function behavior, otherwise it feels a bit weird to have a Fixes tag here. > Signed-off-by: Harshit Mogalapalli > --- > This is spotted by smatch and the patch is only compile tested > > v1->v2: Fix the function panthor_vm_get_heap_pool() to only return error > pointers and handle the caller sites [Suggested by Boris Brezillon] > - Also merge these IS_ERR() vs NULL bugs into same patch > > v2->v3: pull out error checking for devm_drm_dev_alloc() failure. > --- > drivers/gpu/drm/panthor/panthor_drv.c | 4 ++-- > drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++ > drivers/gpu/drm/panthor/panthor_sched.c | 2 +- > 3 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > index 11b3ccd58f85..050b905b0453 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > @@ -1090,8 +1090,8 @@ static int panthor_ioctl_tiler_heap_destroy(struct drm_device *ddev, void *data, > return -EINVAL; > > pool = panthor_vm_get_heap_pool(vm, false); > - if (!pool) { > - ret = -EINVAL; > + if (IS_ERR(pool)) { > + ret = PTR_ERR(pool); > goto out_put_vm; > } > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index fdd35249169f..e1285cdb09ff 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -1893,6 +1893,8 @@ struct panthor_heap_pool *panthor_vm_get_heap_pool(struct panthor_vm *vm, bool c > vm->heaps.pool = panthor_heap_pool_get(pool); > } else { > pool = panthor_heap_pool_get(vm->heaps.pool); > + if (!pool) > + pool = ERR_PTR(-ENOENT); > } > mutex_unlock(&vm->heaps.lock); > > diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c > index 5f7803b6fc48..617df2b980d0 100644 > --- a/drivers/gpu/drm/panthor/panthor_sched.c > +++ b/drivers/gpu/drm/panthor/panthor_sched.c > @@ -1343,7 +1343,7 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id) > if (unlikely(csg_id < 0)) > return 0; > > - if (!heaps || frag_end > vt_end || vt_end >= vt_start) { > + if (IS_ERR(heaps) || frag_end > vt_end || vt_end >= vt_start) { > ret = -EINVAL; > } else { > /* We do the allocation without holding the scheduler lock to avoid