Re: [PATCH] drivers/scsi: Check NULL for kmalloc() return

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2009-08-07 at 14:39 -0400, Davidlohr Bueso A. wrote:
> Verify that ch->dt is not NULL before using it:
> ch-dt[elem] = value;
> 
> Signed-off-by: Davidlohr Bueso

This actually needs to be an email address, not just a name, so

Signed-off-by: Davidlohr Bueso <dave@xxxxxxx>

> ---
>  drivers/scsi/ch.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
> index 7b1633a..96cbd20 100644
> --- a/drivers/scsi/ch.c
> +++ b/drivers/scsi/ch.c
> @@ -353,6 +353,10 @@ ch_readconfig(scsi_changer *ch)
>         /* look up the devices of the data transfer elements */
>         ch->dt = kmalloc(ch->counts[CHET_DT]*sizeof(struct scsi_device),
>                          GFP_KERNEL);
> +
> +       if (!ch->dt)
> +               return -ENOMEM;

This isn't quite right because you'll leak the memory allocated for
buffer here.

For bonus points, the GFP_DMA in the kzalloc() of buffer is bogus ...
this routine can sleep at all points.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux