Re: [PATCH v5 3/3] drm: protect drm_master pointers in drm_lease.c
From: Desmond Cheong Zhi Xi <hidden>
Date: 2021-06-30 06:37:33
Also in:
dri-devel, intel-gfx, linux-media, lkml
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 <redacted> On Tue, 29 Jun 2021 at 04:38, Desmond Cheong Zhi Xi [off-list ref] wrote:quoted
@@ -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.quoted
@@ -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 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees