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

Re: [dm-devel] [PATCH v4 2/5] scsi_dh: add scsi_dh_attached_handler_name



On Thu, 2012-05-17 at 17:23 -0400, Mike Snitzer wrote:
> On Thu, May 17 2012 at  5:12pm -0400,
> Chandra Seetharaman <sekharan us ibm com> wrote:
> 
> > > +/*
> > > + * scsi_dh_attached_handler_name - Get attached device handler's name
> > > + * @q - Request queue that is associated with the scsi_device
> > > + *      that may have a device handler attached
> > > + * @gfp - the GFP mask used in the kmalloc() call when allocating memory
> > > + *
> > > + * Returns name of attached handler, NULL if no handler is attached.
> > > + * Caller must take care to free the returned string.
> > > + */
> > > +const char *scsi_dh_attached_handler_name(struct request_queue *q, gfp_t gfp)
> > > +{
> > > +	unsigned long flags;
> > > +	struct scsi_device *sdev;
> > > +	const char *handler_name = NULL;
> > > +
> > > +	spin_lock_irqsave(q->queue_lock, flags);
> > > +	sdev = q->queuedata;
> > > +	if (!sdev || !get_device(&sdev->sdev_gendev))
> > > +		sdev = NULL;
> > > +	spin_unlock_irqrestore(q->queue_lock, flags);
> > > +
> > > +	if (!sdev)
> > 
> > put_device() missing here.
> 
> Not that I can see.  If sdev is NULL then get_device never succeeded.
> 
> (same pattern is used in scsi_dh_detach)

yup.. overlooked. will send a reviewed-by to the original email
> 
> > > +		return NULL;
> > > +
> > > +	if (sdev->scsi_dh_data)
> > > +		handler_name = kstrdup(sdev->scsi_dh_data->scsi_dh->name, gfp);
> > > +
> > > +	put_device(&sdev->sdev_gendev);
> > > +	return handler_name;
> > > +}
> > > +EXPORT_SYMBOL_GPL(scsi_dh_attached_handler_name);
> > > +
> > >  static struct notifier_block scsi_dh_nb = {
> > >  	.notifier_call = scsi_dh_notifier
> > >  };
> > > Index: linux-2.6/include/scsi/scsi_dh.h
> > > ===================================================================
> > > --- linux-2.6.orig/include/scsi/scsi_dh.h
> > > +++ linux-2.6/include/scsi/scsi_dh.h
> > > @@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct reque
> > >  extern int scsi_dh_handler_exist(const char *);
> > >  extern int scsi_dh_attach(struct request_queue *, const char *);
> > >  extern void scsi_dh_detach(struct request_queue *);
> > > +extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
> > >  extern int scsi_dh_set_params(struct request_queue *, const char *);
> > >  #else
> > >  static inline int scsi_dh_activate(struct request_queue *req,
> > > @@ -80,6 +81,11 @@ static inline void scsi_dh_detach(struct
> > >  {
> > >  	return;
> > >  }
> > > +static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
> > > +							gfp_t gfp)
> > > +{
> > > +	return NULL;
> > > +}
> > >  static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
> > >  {
> > >  	return -SCSI_DH_NOSYS;
> > > 
> > 
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo vger kernel org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



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