lkml.org 
[lkml]   [2013]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch] [SCSI] scsi_transport_sas: check for allocation failure
On Fri, Mar 08, 2013 at 10:50:19PM +0000, James Bottomley wrote:
> On Fri, 2013-03-08 at 12:57 -0500, Douglas Gilbert wrote:
> > On 13-03-08 07:02 AM, Dan Carpenter wrote:
> > > Static checkers complain that this allocation isn't checked. We
> > > should return zero if the allocation fails.
> > >
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > >
> > > diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
> > > index 1b68142..a022997 100644
> > > --- a/drivers/scsi/scsi_transport_sas.c
> > > +++ b/drivers/scsi/scsi_transport_sas.c
> > > @@ -379,9 +379,12 @@ sas_tlr_supported(struct scsi_device *sdev)
> > > {
> > > const int vpd_len = 32;
> > > struct sas_end_device *rdev = sas_sdev_to_rdev(sdev);
> > > - char *buffer = kzalloc(vpd_len, GFP_KERNEL);
> > > + char *buffer;
> > > int ret = 0;
> > >
> > > + buffer = kzalloc(vpd_len, GFP_KERNEL);
> > > + if (!buffer)
> > > + goto out;
> > > if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
> > > goto out;
> > >
> >
> > For 32 bytes, why not use the stack?
>
> Because the buffer is a DMA target. You can't DMA to stack because of
> padding and cacheline issues.
>

I think stack data works here. scsi_execute() calls
blk_rq_map_kern() which handles stack memory and alignment issues.

regards,
dan carpenter


\
 
 \ /
  Last update: 2013-03-11 14:44    [W:0.059 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site