Received: by 10.192.165.148 with SMTP id m20csp3824952imm; Mon, 7 May 2018 20:49:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoK20hQoveKVxN3KzlMC9VYBNyIDmdbYPd3AZm1oQr3PkyrVO+RTwuO0aLF3QbSJ8f9IyhL X-Received: by 10.98.79.12 with SMTP id d12mr38362945pfb.220.1525751385113; Mon, 07 May 2018 20:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525751385; cv=none; d=google.com; s=arc-20160816; b=AhVrC+fxWLf3jRPjOYID1Dpp+Fs7cyWg3+l32VilD5P7NC5rRfNmelmf4qGnD65gpb 3qfcZUt93tkja5hBqi2aFns/W3DvaqMbrimi3R36+pE0kUBtYO9Djm2qJqO2q8awho9O OcYy2hYhQ8MVbTCNlFUTUNx4QXsbdPpz6kKnihWo7YgqVgaMdKWoZLyyulUvKLpRRNBR 0R3BMMJ6ZFbCp4gyXh18oo1No6VTb+h5+tf2YURWsiPsy74uEQiHWdL8WVulBoXCIAQh Ot2YXU588/dgVYZFhRU4b+Wfj9lm3Q/KY2xVOR9tIk8E9S+chySJGcdaPWPsdqKnMnak tXWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=aoxlNrR1aGHK8NYUHYr0V/Ec9mruxk+rbqsYgNax8TY=; b=ZE0Zf78ogOw6c0tdk0vzUFzuusR8jAFU6tmTcv+qJCrFtJQpOFS6Jut1765VoeaAlb pt3bzfh3ypQ8IOsJvFy5v4ZdG3C7z/3A0ShRee1XMxaVRII9VA/5rt/jhyt7HG12yb1E xjIxW5gd/qp/uu7SUqV4Swi7Mr3YXY6kiBV8yYNVynu25SpfIL/o5QfyGYl3vFyVnbI+ 0+JnLcnVJHT+9b7CufA5DC9IqPi+ETuQ6IH/p/XhX8+YM6zx523mWgQJff9sWo+jTIAj F8+W6MElbFXFYTXCIoUmCQ0kIrpy4yg5qffCbvO+BcCfFPBEWHr3Fj+EmPMFZVTzSQ8B sjCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NC8YIRy6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2-v6si20522218plm.379.2018.05.07.20.49.30; Mon, 07 May 2018 20:49:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NC8YIRy6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754300AbeEHDrr (ORCPT + 99 others); Mon, 7 May 2018 23:47:47 -0400 Received: from mail-pl0-f48.google.com ([209.85.160.48]:42052 "EHLO mail-pl0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754283AbeEHDrp (ORCPT ); Mon, 7 May 2018 23:47:45 -0400 Received: by mail-pl0-f48.google.com with SMTP id u6-v6so1380191pls.9; Mon, 07 May 2018 20:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=aoxlNrR1aGHK8NYUHYr0V/Ec9mruxk+rbqsYgNax8TY=; b=NC8YIRy6pOhx56zY6GimnXW3pqkrBl/+t00/+JXLdYmS3KHMXo1UtRC4cDIM8XAUR8 i8QKPRsBiUdJTsszmuyhaTe4VG4tzLmL4W65waNYjrgphP7Xerc196uo0RBQuWbErbWe MbsbER6XpLx50cQ2QtAKn8oH66fnFZGmbus7do4m9G2/hWgZANi5uwps3mUWH4Q1v8YK VpJoXA0vKYhTOiba3TyNGI6IhyttngQ4WQJqFraX3pEOtptkYrYEYtpvVUpPf+Uj+rEP 3kJMX8nbVjhYPilGLVIVayBCnmFHiOnTil9V8Q9tX7+LtBOY3jtUYekb9QcRaZCBn1eP uphg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=aoxlNrR1aGHK8NYUHYr0V/Ec9mruxk+rbqsYgNax8TY=; b=kHL2x9wSOZt8QvRNuCn3l8+fR5dHevzg/gWLt+NHvff/hF8xRbVwBAuReHCDFoQSRI zVpTaYHgIf7cZpAQb2OezIUbAIXVsfzS5zZtYgMSHzBg3xVyxh9YVHZbKDhES2L4r3x4 qDSxnpbNpReK7eKyr4UC26krx8fAqFoMEakGAU26ZtOlHmMGki8sLKk+O+Rj3/gPEUQs +cclzmLE2H9ObEFKGxo6IGfLchy2BanTWXkv+orSkiZ45I3zn7o3L1u8TXmh2dR0lN7D S66Q3ldqAhs3jgdP25swq0UZpuHj8QgQ0B8voMQ0/6egQ0tLOvyPLH/Yz1OrIXf3snJw 2ilw== X-Gm-Message-State: ALQs6tD+d2Kg1abY6igfLYNAihEMZx9ieChMDeVsg5EDwCIvkv9mRPB1 WFytp1E36PSSWE7fmCGgRgVtKKr5 X-Received: by 2002:a17:902:76c4:: with SMTP id j4-v6mr7758347plt.257.1525751264673; Mon, 07 May 2018 20:47:44 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.70.9? ([2402:f000:1:1501:200:5efe:a66f:4609]) by smtp.gmail.com with ESMTPSA id t80sm52944844pfg.0.2018.05.07.20.47.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 20:47:44 -0700 (PDT) Subject: Re: [PATCH] watchdog: mena21_wdt: Fix a possible data race in a21_wdt_set_timeout To: Guenter Roeck , morbidrsa@gmail.com, wim@linux-watchdog.org Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180508031825.12525-1-baijiaju1990@gmail.com> <64e08944-0578-ac4c-8dea-e1e704685e77@roeck-us.net> <26fde8a3-fb78-e12f-2f0f-c9b5bb2158e0@gmail.com> From: Jia-Ju Bai Message-ID: <66ffce75-6528-11d7-311f-2b59f1c2c359@gmail.com> Date: Tue, 8 May 2018 11:47:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/5/8 11:42, Guenter Roeck wrote: > On 05/07/2018 08:32 PM, Jia-Ju Bai wrote: >> >> >> On 2018/5/8 11:28, Guenter Roeck wrote: >>> On 05/07/2018 08:18 PM, Jia-Ju Bai wrote: >>>> The write operation to "wdt->timeout" is protected by >>>> the lock on line 118, but the read operation to >>>> this data on line 105 is not protected by the lock. >>>> Thus, there may exist a data race for "wdt->timeout". >>>> >>>> To fix this data race, the read operation to "wdt->timeout" >>>> should be also protected by the lock. >>>> >>> >>> There is no race. There is already a mutex in the watchdog core >>> which serializes >>> calls to the various API functions. It would make more sense to drop >>> drv->lock >>> from the driver. >>> >> >> Thanks for your reply :) >> Need I submit a patch of dropping all calls to "drv->lock"? >> > > You don't _need_ to, but I would happily give it my Reviewed-by: tag > if you do. > Okay, I will write a patch today :) Best wishes, Jia-Ju Bai