[PATCH 1/2] staging: dgnc: take lock when accessing to dgnc_poll_tick

Salah Triki salah.triki at acm.org
Tue Sep 22 11:02:55 UTC 2015


>On Sun, 6 Sep 2015 20:00:10 -0700, Greg KH wrote:
>>On Sat, Sep 05, 2015 at 01:12:01PM +0100, Salah Triki wrote:
>> poll_tick is declared global, so dgnc_driver_pollrate_* need to
>> take the lock dgnc_poll_lock before accessing to this variable.
>
>Really?  The scope of a variable doesn't matter if a lock is needed for
>it or not.
>
>And this patch doesn't really do anything at all, I don't understand why
>it is needed, please explain.

...
>>  static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp,
>>  char *buf)
>>  {
>> -	return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick);
>> +	unsigned long flags;
>> +	int tick;
>> +
>> +	spin_lock_irqsave(&dgnc_poll_lock, flags);
>
>Why irqsave?  You are never grabbing this lock from within an irq.
>
>I don't think you understand how Linux kernel locks work, or how/where
>they are needed.  Please do a bit more research before creating patches
>like this.
>
>greg k-h

I messed up, please ignore this patch.

best regards
salah triki


More information about the devel mailing list