From patchwork Tue May 31 06:31:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143513 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 08F4D60761 for ; Tue, 31 May 2016 06:32:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1A5027D17 for ; Tue, 31 May 2016 06:32:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6785281C1; Tue, 31 May 2016 06:32:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4A0427D17 for ; Tue, 31 May 2016 06:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755636AbcEaGb5 (ORCPT ); Tue, 31 May 2016 02:31:57 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35610 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755525AbcEaGby (ORCPT ); Tue, 31 May 2016 02:31:54 -0400 Received: by mail-pa0-f65.google.com with SMTP id gp3so17028330pac.2; Mon, 30 May 2016 23:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dPH/Rix0+PwzxtfKlnk3r4kLRE+t/inJOe+QV0SWJxk=; b=LNlUDJPb+E4TT8awm5LmIcEdqU3TlxNRRLuc9gvjtRbKtxzxvqMekeerSlStPLD8U5 +u10ZMp86sKynZOmE/qLcIsWHVOKb86srWz4b1jqUl3KvFLGI04GAbUCcBtZ/+IHyQfI FP4T8RrLUXueZTRbCtRcwjtNDOt5ap2zlApWv2ggrJau3+bjK3gr3T1WAy2Ulmd6hTI6 hSOZRIq/TcQzbMdoFcKeHvWIUiVlwKONEycK62FEewr7+VJSlJvSlane+YRRAWGCVgyv 3bwoz77HwNPccMbeAbbcakEosp515sMNkiAFiHcvtSy8YOPsP5wRMgfscuIdAT8cPAV8 1VwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dPH/Rix0+PwzxtfKlnk3r4kLRE+t/inJOe+QV0SWJxk=; b=YfhoKROHkbILE7cx7FJWcw9hS9uEBqjgNeX00+2PE8ADw2hT32mR0jetgP+ollP0oL l9ZYQ9VcPonYWTXeKF8nYxQCzUyxHBbM/sj1r17T7TOkoOW/lPhcaZ8c3QtVy7SO/Jku vCxTtKMyHIaYbhV3R1HyloSNFiANzGY6wwPjNLRQl9rgmbGgnJnxzMjfewR5e+rbyr1o eYcAdxF0YnP7PA2yl6oftABHATob4PhV4N7LIOdA+Z8ZdALVqb/CS2yx6bf4/g+ODE4i Q32XTY6Lq4a9acJDsKVN0CCksYZBscdWxgu198qCTkHqFBq7RH86X0n+rxuqY4hRTSdB +gdA== X-Gm-Message-State: ALyK8tIqXU0VIVpDVvRulw+4PN/dMFQukVmnBvtn4tXxzeHnOS+Od9dSMedrHGFJXLp7Bw== X-Received: by 10.66.179.169 with SMTP id dh9mr52487617pac.133.1464676314149; Mon, 30 May 2016 23:31:54 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id cc6sm51739456pac.5.2016.05.30.23.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:31:53 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 01/15] thermal: sysfs: lock tz in type_show Date: Mon, 30 May 2016 23:31:22 -0700 Message-Id: <1464676296-5610-2-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464676296-5610-1-git-send-email-edubezval@gmail.com> References: <1464676296-5610-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid race while accessing tz->type. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_sysfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 4136b71..ee983ca 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -29,8 +29,13 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct thermal_zone_device *tz = to_thermal_zone(dev); + char *type; - return sprintf(buf, "%s\n", tz->type); + mutex_lock(&tz->lock); + type = tz->type; + mutex_unlock(&tz->lock); + + return sprintf(buf, "%s\n", type); } static ssize_t