Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp66835pxv; Tue, 29 Jun 2021 23:38:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1svvWr152EHX5LJIKLhGNJ4VnJN5YkJB1FrWvqQT/c3d+ZmXBxdgrg+erx7vtvzDeGbaS X-Received: by 2002:aa7:d892:: with SMTP id u18mr45313350edq.196.1625035131683; Tue, 29 Jun 2021 23:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625035131; cv=none; d=google.com; s=arc-20160816; b=VRnovZfw/1noX8mAEmXY29KjFE33B9gDYpGYe6tiWgkmFxG4GShlJ27FeixEtmTzvw 0zVZ86PGbHFxT0JVnE33Jrw3u3bFnab14lTgaNUPtWJSMMUPyINzMkCRuIjGsUvScPR4 2RQnUxp9hFqQ7sfiMtRtU9r87t61qUclhuXHZQv7JqmbPuQVVFntkihnrvF1ZBI7dLS1 9EPYdvWXOmgWbWzIea1SxPOIFSR+M2I8wvHd/+X9qACQHTz+tdWxKEptaG14XCNqNZMn Dp5gT4WG1/xH5gQaZdhed8K+hjq1wHPlz6yR+bXo0kvDwtfSr3HtKZuFG4X4GPyAHcj5 fnIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=QIvNKpu6whR4KbUvMINCyHMH+hf3gIcrSC/Vwhdr3Lw=; b=qpGQiQYFhNALS36f2h3zb7jA7kEZzDVGuH7ZNx/6Pyh3x1DJ91QxOATHCj6B4PyP3k 6qTStL1bI0jopT89oIaHAx/1TKmBYyee5c/h03FBnVFRbzeGd8f5QjYxsR/9ee9C92UW CHXi7CVCGD1mF4aJX/szNl7f7FuIsydheLoOTz54bMZlGnI+L6dgPYikbki7kSYPX/Hk WjJEpto6c9aN7/aWU9AYWQStplyR6PNiKGvb5Q9MJz6UXuOPUqoP1mIRPbOYKSpqcC90 n3vyOfPqXb24IiVREw5PWHIWEWIGA1L4SCFrZhfhTc67yYJ/22GqomPQaNIE1giP4cgd mMPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YNGt9ANU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp16si24605749ejc.434.2021.06.29.23.38.28; Tue, 29 Jun 2021 23:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YNGt9ANU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232445AbhF3Gj7 (ORCPT + 99 others); Wed, 30 Jun 2021 02:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbhF3Gj6 (ORCPT ); Wed, 30 Jun 2021 02:39:58 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73E6C061766; Tue, 29 Jun 2021 23:37:29 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id y17so1233771pgf.12; Tue, 29 Jun 2021 23:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=QIvNKpu6whR4KbUvMINCyHMH+hf3gIcrSC/Vwhdr3Lw=; b=YNGt9ANUzqBZpiARnaJOzXbbBqylmMuYP/nI/dR8iVc9BR8fyloomrSEDAc7BHhB1t 3TGc7sm8bxGH/Kh9sl8FHkfQJSb9d3wZc8s8UirITisqGy/BMijpPFumavBt9BKtTU5t KzteOijczl9A4g7/s10zsj2dYedhe1Fapf+4S2kq7X8GW4dWZ0TB6l4xKWnCaHJBb3yv aCAHePk8renhA6LzrrWsTBRGjtv5j4O5a8Au8q3RkfIywGYHTOT0+daMkNfKzK0g8ow7 H32WH1O2xZUCj3wKo23i3lBi3mlxMgE9oEMsxMx30Gk6CRC9uoOiSUHvfb+/212Ng/q9 bXPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QIvNKpu6whR4KbUvMINCyHMH+hf3gIcrSC/Vwhdr3Lw=; b=XUcM7x70yCkNmJaB+EhyAAUMXCbxnPI4RKVVjOBN7jru8x1m4I7+xLn3XsmdrMdioL 907WagfbuVYNvcCvJqlf5lnAba4YQIeWYoO1Vr7dFspNXj7DgwbIyBu06gsQL8/cLYXx f53EsNMi44FjwjE64ubppJ/GzzD37tvUICUTklhJd5VFLSVsPeDjitvBHVV6IWHkxvoO DyEaJZ6ADUfU9KGgLFZplvhcgtIYntj+9Tem4wNrbeH1/M3maT/HbTnwaNqFzClwODlN 2AxKc06O20KSW5N0S+oxyQBh83lQUQJEtjVrDNyNOr9hUcMhyte44egMct5azyAkMEjw oABg== X-Gm-Message-State: AOAM531gdZZ8usUa8e2sYOLus3PqWQ3bOJDb2JA292TaDWFZgRnJIRtP Qtv7yovd/sds6xztGAwP1iE= X-Received: by 2002:a63:2f05:: with SMTP id v5mr32113452pgv.449.1625035049301; Tue, 29 Jun 2021 23:37:29 -0700 (PDT) Received: from [192.168.1.237] ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id h24sm20304574pjv.27.2021.06.29.23.37.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 23:37:28 -0700 (PDT) Subject: Re: [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c To: Emil Velikov Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Dave Airlie , Daniel Vetter , Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , ML dri-devel , Intel Graphics Development , "Linux-Kernel@Vger. Kernel. Org" , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, skhan@linuxfoundation.org, Greg Kroah-Hartman , linux-kernel-mentees@lists.linuxfoundation.org, Daniel Vetter References: <20210629033706.20537-1-desmondcheongzx@gmail.com> <20210629033706.20537-4-desmondcheongzx@gmail.com> From: Desmond Cheong Zhi Xi Message-ID: Date: Wed, 30 Jun 2021 14:37:23 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/6/21 8:16 am, Emil Velikov wrote: > Hi Desmond, > > Couple of small suggestions, with those the series is: > Reviewed-by: Emil Velikov > > On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi > wrote: > >> @@ -128,13 +137,20 @@ bool drm_lease_held(struct drm_file *file_priv, int id) >> struct drm_master *master; >> bool ret; >> >> - if (!file_priv || !file_priv->master || !file_priv->master->lessor) >> + if (!file_priv) >> return true; >> >> - master = file_priv->master; >> + master = drm_file_get_master(file_priv); >> + if (master == NULL) >> + return true; >> + if (!master->lessor) { >> + drm_master_put(&master); >> + return true; > > Let's add a "ret = true; goto unlock;" here, so we can have a single > drm_master_put() in the function. > Nearly all code paths touched by this patch already follow this approach. > >> @@ -154,10 +170,16 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in) >> int count_in, count_out; >> uint32_t crtcs_out = 0; >> >> - if (!file_priv || !file_priv->master || !file_priv->master->lessor) >> + if (!file_priv) >> return crtcs_in; >> >> - master = file_priv->master; >> + master = drm_file_get_master(file_priv); >> + if (master == NULL) >> + return crtcs_in; >> + if (!master->lessor) { >> + drm_master_put(&master); >> + return crtcs_in; > > Ditto > > Thanks > Emil > Sounds good to me, I'll revise these functions. Thanks for the review and suggestions, Emil. Best wishes, Desmond