lkml.org 
[lkml]   [2007]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: lirc: igorplususb error handling cleanup
Date

> > - /* allocate kernel memory */
> > - mem_failure = 0;
> > - if (!(ir = kmalloc(sizeof(struct irctl), GFP_KERNEL))) {
> > - mem_failure = 1;
> > - } else {
> > - memset(ir, 0, sizeof(struct irctl));
> > -
> > - if (!(plugin = kmalloc(sizeof(struct lirc_plugin), GFP_KERNEL))) {
> > - mem_failure = 2;
> > - } else if (!(rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL))) {
> > - mem_failure = 3;
>
> If size of all structs, allocated here is 3-4 pages (say, 4096 bytes
> one), then, i think something like, allocating all at once may be
> utilized:
>
> ,-*-
> |struct ir_stuff_t {
> | struct irctl *ir;
> | struct lirc_plugin *plugin;
> | struct lirc_buffer *rbuf;

I guess you mean
struct lirc_buffer rbuf;
without the "*"

> |} ir_stuff;
> |
> |ir_stuff = kzalloc(...);
> |
> |if(!ir_stuff)
> | error;
> `-*-
>
> then join buffer init, usb init together and final register, after
> it. Thus to have second erroneous path.

If I understand this code correctly the allocated buffers end up as
buffers used in URBs. If that is the case you must allocate each of
them separately with kmalloc() or usb_alloc_buffer() or you violate
DMA constraints on non-coherent architectures (eg. ppc)

Regards
Oliver
-
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/

\
 
 \ /
  Last update: 2007-02-02 12:01    [W:0.254 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site