RE: [PATCH 3/9] staging: unisys: visorinput: use kref ref-counting for device data struct

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

 



> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@xxxxxxxxxx]
> Sent: Friday, October 16, 2015 9:03 PM
> To: Romer, Benjamin M
> Cc: gregkh@xxxxxxxxxxxxxxxxxxx; *S-Par-Maintainer; driverdev-
> devel@xxxxxxxxxxxxxxxxxxxxxx; Sell, Timothy C
> Subject: Re: [PATCH 3/9] staging: unisys: visorinput: use kref ref-counting
> for device data struct
> 
> On Fri, Oct 16, 2015 at 10:06:48AM -0400, Benjamin Romer wrote:
> > @@ -526,7 +549,8 @@ visorinput_channel_interrupt(struct visor_device
> *dev)
> >  	int xmotion, ymotion, zmotion, button;
> >  	int i;
> >
> > -	struct visorinput_devdata *devdata = dev_get_drvdata(&dev-
> >device);
> > +	struct visorinput_devdata *devdata =
> > +		devdata_get(dev_get_drvdata(&dev->device));
> >
> >  	if (!devdata)
> >  		return;
> > @@ -616,6 +640,7 @@ visorinput_channel_interrupt(struct visor_device
> *dev)
> >  		}
> >  	}
> >  out_locked:
> > +	devdata_put(devdata);
> >  	up_write(&devdata->lock_visor_dev);
> >  }
> 
> Always release resources in the reverse order from how they were taken.
> So we call devdata_put() after up_write().  Otherwise it looks like a
> use after free or something.
> 
> regards,
> dan carpenter

Good point; thanks.  I generally follow that rule, but somehow missed it this
time.  We'll re-submit this patch with those lines reversed, as you suggest.

Tim Sell

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux