From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Christian_K=F6nig?= Date: Fri, 20 Jul 2012 13:45:28 +0000 Subject: Re: [patch] drm/radeon: check for allocation failure in radeon_ring_backup() Message-Id: <500960F8.6060906@vodafone.de> List-Id: References: <20120720111700.GB22245@elgon.mountain> In-Reply-To: <20120720111700.GB22245@elgon.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Dan Carpenter Cc: kernel-janitors@vger.kernel.org, =?ISO-8859-1?Q?Michel_D=E4nz?= =?ISO-8859-1?Q?er?= , dri-devel@lists.freedesktop.org, Jerome Glisse , Alex Deucher , Dave Airlie On 20.07.2012 13:17, Dan Carpenter wrote: > Static checkers complain if this we don't check for allocation failure. > Also we can use the new kmalloc_array() function here as a cleanup. > > Signed-off-by: Dan Carpenter What's the benefit of using kmalloc_array instead of just kmalloc? Anyway it's: Reviewed-by: Christian K=F6nig > > diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeo= n/radeon_ring.c > index 75cbe46..5a0ef24 100644 > --- a/drivers/gpu/drm/radeon/radeon_ring.c > +++ b/drivers/gpu/drm/radeon/radeon_ring.c > @@ -402,7 +402,11 @@ unsigned radeon_ring_backup(struct radeon_device *rd= ev, struct radeon_ring *ring > } > =20 > /* and then save the content of the ring */ > - *data =3D kmalloc(size * 4, GFP_KERNEL); > + *data =3D kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); > + if (!*data) { > + mutex_unlock(&rdev->ring_lock); > + return 0; > + } > for (i =3D 0; i < size; ++i) { > (*data)[i] =3D ring->ring[ptr++]; > ptr &=3D ring->ptr_mask; > -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Christian_K=F6nig?= Subject: Re: [patch] drm/radeon: check for allocation failure in radeon_ring_backup() Date: Fri, 20 Jul 2012 15:45:28 +0200 Message-ID: <500960F8.6060906@vodafone.de> References: <20120720111700.GB22245@elgon.mountain> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable Return-path: Received: from outgoing.email.vodafone.de (outgoing.email.vodafone.de [139.7.28.128]) by gabe.freedesktop.org (Postfix) with ESMTP id D04069F378 for ; Fri, 20 Jul 2012 06:45:34 -0700 (PDT) In-Reply-To: <20120720111700.GB22245@elgon.mountain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Dan Carpenter Cc: kernel-janitors@vger.kernel.org, =?ISO-8859-1?Q?Michel_D=E4nz?= =?ISO-8859-1?Q?er?= , dri-devel@lists.freedesktop.org, Jerome Glisse , Alex Deucher , Dave Airlie List-Id: dri-devel@lists.freedesktop.org On 20.07.2012 13:17, Dan Carpenter wrote: > Static checkers complain if this we don't check for allocation failure. > Also we can use the new kmalloc_array() function here as a cleanup. > > Signed-off-by: Dan Carpenter What's the benefit of using kmalloc_array instead of just kmalloc? Anyway it's: Reviewed-by: Christian K=F6nig > > diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeo= n/radeon_ring.c > index 75cbe46..5a0ef24 100644 > --- a/drivers/gpu/drm/radeon/radeon_ring.c > +++ b/drivers/gpu/drm/radeon/radeon_ring.c > @@ -402,7 +402,11 @@ unsigned radeon_ring_backup(struct radeon_device *rd= ev, struct radeon_ring *ring > } > = > /* and then save the content of the ring */ > - *data =3D kmalloc(size * 4, GFP_KERNEL); > + *data =3D kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); > + if (!*data) { > + mutex_unlock(&rdev->ring_lock); > + return 0; > + } > for (i =3D 0; i < size; ++i) { > (*data)[i] =3D ring->ring[ptr++]; > ptr &=3D ring->ptr_mask; >