Re: [PATCH v2 1/2] serial: core: make static analyzer happy about locks

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

 



On Mon, Nov 21, 2016 at 03:17:16PM +0200, Andy Shevchenko wrote:
> On Mon, 2016-11-21 at 13:29 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 16, 2016 at 08:06:32PM +0200, Andy Shevchenko wrote:
> > > Static analyzer can not see balanced locking if the lock is acquired
> > > and
> > > released conditionally.
> > > 
> > > drivers/tty/serial/serial_core.c:131:17: warning: context imbalance
> > > in 'uart_stop' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_start' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_put_char' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_write' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_write_room' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_chars_in_buffer' - unexpected unlock
> > > include/linux/spinlock.h:362:9: warning: context imbalance in
> > > 'uart_flush_buffer' - unexpected unlock
> > > 
> > > Get rid of macros and implement their functionality in place. This
> > > will also
> > > help to enable runtime PM in more clean way later.
> > 
> > Really?  Because now the code is harder to follow from a "what is this
> > doing" point of view as you have to duplicate logic in a number of
> > different places.
> 
> We have number of places in kernel where we take reference count of
> something and then using spin lock. I don't see how this makes harder to
> follow.

You are "open-coding" these macros, for no other reason than to silence
a tool that is incorrect.  This makes further changes in the code harder
to make.

> > What happened to making these just static inline functions instead?
> 
> So, the function needs annotation for checker and flags parameter will
> go like a) taking address of it, b) dereference it.
> 
> For me it will look not shiny.

This looks worse than the code today, a very non-shiny patch as-is,
sorry, but I'm not going to take this.

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



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux