From patchwork Fri Jun 9 09:59:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 103450 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp128417qgd; Fri, 9 Jun 2017 03:01:07 -0700 (PDT) X-Received: by 10.84.218.78 with SMTP id f14mr39597166plm.214.1497002467577; Fri, 09 Jun 2017 03:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497002467; cv=none; d=google.com; s=arc-20160816; b=rNVpsDdTuO40aPH8bDVerKeODV44VxaGn7mFfggkKJ2bzHdp5r0/AM8apoR1pRvpqY OUOyDGFMXL6hOj9znJ2jHwyU5vywRz8zhzDta4a1nqEZemhKD18NAE5u3cDC4425hHQB AJJtxH8yot8InVnxMPJkMJt0fSqYY9jEJo8PDdfP4eLtwjpJh1xc35Bww5/x+ig1bNU1 AND5SZk4Ukbpn2cl3M+XMFrnfNFiXMYWz5k5VEL+gWrlmWPUX72obCGo5kL++mdKz+5T kvdd/iVplIZbwBeka3cCJKHL9cVu31vm80Atj64WEfWFv9gYBe3cJ1wz92Cg5lh4yznL nY4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4ZgAoXdiEHfJxkMowZm763/qYb3veIRjJzruAcT81YI=; b=ODY7aTemPvrO3T3eBcbvGr1Rj9lk3yduaBBMdr5ITfaU0Yj8XfxWKXxkHYvz0koEMl 8ZaUt1POj15DNH5f31kUMh2u1clnGVQ193HEOBupjvMTlFkHzIBJvSKgI7ExTJlC4H0x vh7YxpBSJ+xQW83NojVj9T7UuyQrhze2mjnMMFeLZP1N5GZa4yuDaLefSHC07V96VbvM 8961irniWcAN49NSET6dVjr3yWQhIIUdD9EYODsxKbKkv4A5VfE7GOzB39p1PbrZ3xQp g/cmbRxEPJCbElMr0M08Zcrzpn59XdqtpnZerG6T2qvDyjk3jC54LsdS/aXN9qmTIhSa rjUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si563638pli.453.2017.06.09.03.01.07; Fri, 09 Jun 2017 03:01:07 -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=@linaro.org; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751785AbdFIKAp (ORCPT + 25 others); Fri, 9 Jun 2017 06:00:45 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:34390 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbdFIJ7o (ORCPT ); Fri, 9 Jun 2017 05:59:44 -0400 Received: by mail-wr0-f182.google.com with SMTP id g76so28194283wrd.1 for ; Fri, 09 Jun 2017 02:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ZgAoXdiEHfJxkMowZm763/qYb3veIRjJzruAcT81YI=; b=PynZTKPW+Jjf+AYJ96AVScybXUq+UW5mYvqcIlDrUtKUMnafBQf+E39vdcHxfB4rAV H/ArCYZZ57R+dxwUBk0cwm1Mb7FRjkvWF3GQxhTPnS3GDGoN74YKBHLUY/3GnZxFcMWp qt57yuRwrty3cwLwhFqdXa70ZW1I5T3RMToh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4ZgAoXdiEHfJxkMowZm763/qYb3veIRjJzruAcT81YI=; b=mqE8iB2Ssp7kQ3rqzDDgtZc1EPaN5/PryIhPrTFldN2hgRpFl2/EuxC1cCzRCuskFf 3lsMA84+/Vdqz/O9Wy0+MA/ehB/IOn5LWoNLLodWpgB2SGGemGtQinSIgXtXStLMLvkH wl10C5xKpCl3oleiYOSJbcJ9PVefns6Vk0Trtr4wVwTYUJlwHbsI62TRLXqT3Yrax0p0 RrNsjh+UP2ZcK57uUzj9NDpdISrHW4x3CRWdpTBsucIZb8nFlIMofOXHEifI9pECkIZy w8QJEDievVAsJZssAK80MlRjpsSOpE2U8uQr0qlopJ5yaGSJ37BfUBlKtODsaSZT2vzL /21w== X-Gm-Message-State: AODbwcBIbxcxGw6l3fbbfizG3lSUAzqOUEa6JP3q9hhaOYJGq8rQJjHx XEMCtzAwL++jiBf7 X-Received: by 10.223.145.75 with SMTP id j69mr27472642wrj.23.1497002383066; Fri, 09 Jun 2017 02:59:43 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id g46sm1031207wrg.69.2017.06.09.02.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 02:59:42 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: srinivas.kandagatla@linaro.org, linux-kernel@vger.kernel.org, Heiner Kallweit Subject: [PATCH 4/5] nvmem: core: add locking to nvmem_find_cell Date: Fri, 9 Jun 2017 10:59:09 +0100 Message-Id: <20170609095910.4090-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170609095910.4090-1-srinivas.kandagatla@linaro.org> References: <20170609095910.4090-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiner Kallweit Adding entries to nvmem_cells and deleting entries from it is protected by nvmem_cells_mutex. Therefore this mutex should also protect iterating over the list. Signed-off-by: Heiner Kallweit Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 0cbac71195b5..4c49285168fb 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -287,9 +287,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(&nvmem_cells_mutex); + list_for_each_entry(p, &nvmem_cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(&nvmem_cells_mutex); return p; + } + + mutex_unlock(&nvmem_cells_mutex); return NULL; }