kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple@vodafone.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kernel-janitors@vger.kernel.org,
	"Michel Dänzer" <michel.daenzer@amd.com>,
	dri-devel@lists.freedesktop.org,
	"Jerome Glisse" <jglisse@redhat.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Dave Airlie" <airlied@redhat.com>
Subject: Re: [patch] drm/radeon: check for allocation failure in radeon_ring_backup()
Date: Fri, 20 Jul 2012 13:45:28 +0000	[thread overview]
Message-ID: <500960F8.6060906@vodafone.de> (raw)
In-Reply-To: <20120720111700.GB22245@elgon.mountain>

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 <dan.carpenter@oracle.com>
What's the benefit of using kmalloc_array instead of just kmalloc?

Anyway it's:

Reviewed-by: Christian König <christian.koenig@amd.com>

>
> diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/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 *rdev, struct radeon_ring *ring
>   	}
>   
>   	/* and then save the content of the ring */
> -	*data = kmalloc(size * 4, GFP_KERNEL);
> +	*data = kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL);
> +	if (!*data) {
> +		mutex_unlock(&rdev->ring_lock);
> +		return 0;
> +	}
>   	for (i = 0; i < size; ++i) {
>   		(*data)[i] = ring->ring[ptr++];
>   		ptr &= 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

  reply	other threads:[~2012-07-20 13:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 11:17 [patch] drm/radeon: check for allocation failure in radeon_ring_backup() Dan Carpenter
2012-07-20 13:45 ` Christian König [this message]
2012-07-20 14:35   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=500960F8.6060906@vodafone.de \
    --to=deathsimple@vodafone.de \
    --cc=airlied@redhat.com \
    --cc=alexander.deucher@amd.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jglisse@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=michel.daenzer@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).