Re: [PATCH 4/4] cdrom: revert commit 22a9189 (cdrom: use kmalloced buffers instead of buffers on stack)

Elias Oltmanns
2008-05-20T07:33:00Z

FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> The commit 22a9189fd073db3d03a4cf8b8c098aa207602de1 (cdrom: use
> kmalloced buffers instead of buffers on stack) is introduced to use
> kmalloced buffers for packet commands to avoid stack corruption on non
> coherent platforms.
>
> SCSI cdrom uses blk_rq_map_kern (the commit
> 68154e90c9d1492d570671ae181d9a8f8530da55) post 2.6.25. So sr_packet
> uses allocated pages when necessary. IDE cdrom has a mechnism to
> handle alignment and padding. So we don't need this extra complexitiy
> in cdrom.c.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Jens Axboe <jens.axboe@oracle.com>
[...]
> @@ -837,14 +796,10 @@ static int cdrom_mrw_open_write(struct cdrom_device_info *cdi)
> static int mo_open_write(struct cdrom_device_info *cdi)
> {
> struct packet_command cgc;
> - char *buffer;
> + char buffer[255];
> int ret;
>
> - buffer = kmalloc(255, GFP_KERNEL);
> - if (!buffer)
> - return -ENOMEM;
> -
> - init_cdrom_command(&cgc, buffer, 4, CGC_DATA_READ);
> + init_cdrom_command(&cgc, &buffer, 4, CGC_DATA_READ);
^
Careful here.

Regards,

Elias