mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyle McMartin <kyle@mcmartin.ca>
To: wzt.wzt@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	kyle@mcmartin.ca, deller@gmx.de, jejb@parisc-linux.org
Subject: Re: [PATCH] Parisc: Check kmalloc return value before use the buffer in ccio-dma.c
Date: Thu, 6 May 2010 00:03:31 -0400	[thread overview]
Message-ID: <20100506040331.GC4902@bombadil.infradead.org> (raw)
In-Reply-To: <20100506024208.GB15956@localhost.localdomain>

On Thu, May 06, 2010 at 10:42:08AM +0800, wzt.wzt@gmail.com wrote:
> +	if (!name) {
> +		printk(KERN_ERR "%s() failed to get enough memory\n", __func__);
> +		return ;
> +	}
> +
>  	snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path);

This code can't fail, since the failure case won't be handled by the
probe function, and will continue along without properly initializing
the resources and will fail later. While we could add proper error
handling, if these functions are called, the ccio IOMMU exists on the
machine, and without it, we can't do any DMA (amongst other things.)
So in that case, if this kmalloc fails (which it really shouldn't...)
we're pretty much screwed.

We can change it to GFP_ATOMIC|__GFP_NOFAIL so it will retry infinitely,
or we can panic in the error path with a nice error message so the users
knows why his machine isn't going to work.

I suggest the latter since you'll have the test to squelch gcc warnings
and such.

regards, Kyle


  reply	other threads:[~2010-05-06  4:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06  2:42 wzt.wzt
2010-05-06  4:03 ` Kyle McMartin [this message]
2010-05-06 10:59   ` Matthew Wilcox
2010-05-06 20:08     ` Kyle McMartin

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=20100506040331.GC4902@bombadil.infradead.org \
    --to=kyle@mcmartin.ca \
    --cc=deller@gmx.de \
    --cc=jejb@parisc-linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=wzt.wzt@gmail.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

all inboxes | Powered by JetHome®