Re: [patch] bus: sunxi-rsb: unlock on error in sunxi_rsb_read()

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

 




On Wed, 4 Nov 2015, walter harms wrote:

>
>
> Am 03.11.2015 23:02, schrieb Dan Carpenter:
> > Don't forget to unlock before returning an error code.
> >
> > Fixes: d787dcdb9c8f ('bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus')
> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> >
> > diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
> > index 846bc29c..0cfcb39 100644
> > --- a/drivers/bus/sunxi-rsb.c
> > +++ b/drivers/bus/sunxi-rsb.c
> > @@ -342,13 +342,13 @@ static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr,
> >
> >  	ret = _sunxi_rsb_run_xfer(rsb);
> >  	if (ret)
> > -		goto out;
> > +		goto unlock;
> >
> >  	*buf = readl(rsb->regs + RSB_DATA);
> >
> > +unlock:
> >  	mutex_unlock(&rsb->lock);
> >
> > -out:
> >  	return ret;
> >  }
> >
>
> microoptimisation:
> You can remove the goto.
>
> if (!ret)
> 	*buf = readl(rsb->regs + RSB_DATA);
>
> mutex_unlock(&rsb->lock);
> return ret;

I think the goto is nicer.  Failure => goto.

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux