Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932597Ab0GUAbL (ORCPT ); Tue, 20 Jul 2010 20:31:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39221 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753801Ab0GUAbJ (ORCPT ); Tue, 20 Jul 2010 20:31:09 -0400 Subject: Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer derefernce From: Dave Airlie To: "Alexander Y. Fomichev" Cc: Alex Deucher , Robert Noland , Matt Turner , Jerome Glisse , akpm@linux-foundation.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org In-Reply-To: References: <20100720014251.46b91cdd@mad-cat.localdomain> Content-Type: text/plain; charset="UTF-8" Date: Wed, 21 Jul 2010 10:30:43 +1000 Message-ID: <1279672243.337.10.camel@clockmaker-el6> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3002 Lines: 79 On Wed, 2010-07-21 at 01:07 +0400, Alexander Y. Fomichev wrote: > On Wed, Jul 21, 2010 at 1:00 AM, Alex Deucher wrote: > > On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev > > wrote: > >> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher wrote: > >>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev > >>> wrote: > >>>> This patch fix possible NULL pointer dereference when > >>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv > >>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be > >>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN. > >>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375 > >>>> > >>>> --- > >>>> drivers/gpu/drm/radeon/r600_blit.c | 2 ++ > >>>> 1 files changed, 2 insertions(+), 0 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c > >>>> index f4fb88e..0df4a2b 100644 > >>>> --- a/drivers/gpu/drm/radeon/r600_blit.c > >>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c > >>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) > >>>> DRM_DEBUG("\n"); > >>>> > >>>> r600_nomm_get_vb(dev); > >>>> + if (!dev_priv->blit_vb) > >>>> + return; > >>> > >>> r600_prepare_blit_copy returns an int so something like this would be better: > >>> --- a/drivers/gpu/drm/radeon/r600_blit.c > >>> +++ b/drivers/gpu/drm/radeon/r600_blit.c > >>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, > >>> struct drm_file *file_priv) > >>> { > >>> drm_radeon_private_t *dev_priv = dev->dev_private; > >>> DRM_DEBUG("\n"); > >>> + int ret = r600_nomm_get_vb(dev); > >>> > >>> - r600_nomm_get_vb(dev); > >>> + if (ret) > >>> + return ret; > >>> > >>> dev_priv->blit_vb->file_priv = file_priv; > >>> > >>> > >>> Alex > >>> > >>>> > >>>> dev_priv->blit_vb->file_priv = file_priv; > >>>> > >>>> -- > >>>> 1.7.1.1 > >>>> > >>> > >> > >> i haven't any preferneces, the only thing is - it would be logical > >> to have every check in common style, so other cases > >> (r600_blit_copy, r600_blit_swap) should be fixed, nop? > > > > Those are void functions so there's nothing to return. > > i mean both of them call r600_nomm_get_vb and both of them > check if (!dev_priv->blit_vb), not return value.I mean would be > logical to check it the same way everytime r600_nomm_get_vb > gets called. I'm going to go with Alex's patch, as none of the other callsites return an error, and your patch doesn't return value from a function which has a int return type, causing a warning. Dave. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/