From: Sam Ravnborg Subject: Re: [PATCH] drm/atomic-helper: Validate pointer before dereference Date: Mon, 11 Mar 2019 22:47:08 +0100 Message-ID: <20190311214708.GB24416@ravnborg.org> References: <20190311210120.fdixvenmqjoxuoqt@smtp.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190311210120.fdixvenmqjoxuoqt@smtp.gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: Rodrigo Siqueira Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Gerd Hoffmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org Hi Rodrigo On Mon, Mar 11, 2019 at 06:01:20PM -0300, Rodrigo Siqueira wrote: > The function disable_outputs() and > drm_atomic_helper_commit_modeset_enables() tries to retrieve > helper_private from the target CRTC, for dereferencing some operations. > However, the current implementation does not check whether > helper_private is null and, if not, if it has a valid pointer to a dpms > and commit functions. This commit adds pointer validations before > trying to dereference the dpms and commit function. > > Signed-off-by: Rodrigo Siqueira > --- > drivers/gpu/drm/drm_atomic_helper.c | 30 ++++++++++++++++------------- > 1 file changed, 17 insertions(+), 13 deletions(-) > > @@ -1277,11 +1279,13 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, > if (new_crtc_state->enable) { > DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n", > crtc->base.id, crtc->name); This DEBUG_ print is only relevant if the code actually do something in the following. So it seems more correct to fix the upper if () to: > if (new_crtc_state->enable && funcs != NULL) { > DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n", ... The you also loose one indent and the calls are nicer. (If used "funcs != NULL", but this is a matter of taste). Sam