Re: [PATCH 1/3] scsi_dh: Add modalias support for SCSI targets

James Bottomley
2009-03-18T14:02:52Z

On Wed, 2009-03-18 at 09:44 -0400, Konrad Rzeszutek wrote:
> .. snip..
> > static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
> > {
> > struct scsi_device *sdev;
> > + char buffer[501];
>
> Why '501' ? How did you come up with that number?

A random 500 bytes of data plus room for a string terminator?

> > + int rc;
> >
> > if (dev->type != &scsi_dev_type)
> > return 0;
> >
> > sdev = to_scsi_device(dev);
> >
> > - add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
> > + buffer[500] = '\0';
>
> Shouldn't that be buffer[501] ?

No, buffer[501] would be off the end of the reserved space. The
definition char buf[501] allows you to access from buf[0] to buf[500].

James