Re: [PATCH] staging: zcache: make sure client id is valid

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

 



On Wed, Oct 17, 2012 at 08:05:36AM -0700, Greg KH wrote:
> On Wed, Oct 17, 2012 at 12:57:50PM +0800, Yuanhan Liu wrote:
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@xxxxxxxxxxxxxxx>
> > ---
> 
> Why?  What is this solving/fixing/doing?
> 
> >  drivers/staging/zcache/zcache-main.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
> > index 52b43b7..fb68af6 100644
> > --- a/drivers/staging/zcache/zcache-main.c
> > +++ b/drivers/staging/zcache/zcache-main.c
> > @@ -68,10 +68,14 @@ static struct zcache_client zcache_clients[MAX_CLIENTS];
> >  
> >  static inline uint16_t get_client_id_from_client(struct zcache_client *cli)
> >  {
> > +	uint16_t cli_id;
> > +
> >  	BUG_ON(cli == NULL);
> >  	if (cli == &zcache_host)
> >  		return LOCAL_CLIENT;
> > -	return cli - &zcache_clients[0];
> > +	cli_id = cli - &zcache_clients[0];
> > +	BUG_ON(cli_id > MAX_CLIENTS);
> 
> How nice, you just crashed the whole machine.  Don't do that.

I see.

Thanks,
Yuanhan Liu
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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