From patchwork Mon Jan 28 15:55:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 156799 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3691143jaa; Mon, 28 Jan 2019 09:35:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6N2chRpcvImU3RVAYV74Cy2aZPgOImo7LcSloIn+2/9RS+Z/P89GGOG+fpVKMKR2glmWn4 X-Received: by 2002:a62:d148:: with SMTP id t8mr23277809pfl.52.1548696921399; Mon, 28 Jan 2019 09:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696921; cv=none; d=google.com; s=arc-20160816; b=MHe/sP9aNxp7w4tCUdqaUegVDyPJsVuOXFZ/f92FlFUEDwOAP82nmk8LiMwavrK8vW RdXAiNlqo4hw3qBefcdWNNeQRWGw7rsk0EsUrVKlkT5jsO0taLbCY7QD0yX9/7NcJ1RB LsRJPGuzClkrMYKRWTGqF/RNUW890sxqV1+f6lvm2hg1BoGgtOifz+EHl3nkEMaZ3QJx FNGYKLqdlhAeqBrsBLW84zBB3HScagXtlgkxTZbI2sCu4I6DxikUA4qbbvgSiE7Zfqrw jfqmpcCqZhDZkANamQolttCaJEXt1e7fKUkLPwXISh30VEe+5M6i8No9cc6agd3GGQ2i jKPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lZsyg31nN3cTqKBQ+cnJv/eVAHpsVh0TDVW8eJ9YX1U=; b=PeQ7y42K9dQCYfGk5bJzb9sl8Xrist1NcSRH/7NIdKOTLoj4QbJidOxh02VIjKKMd0 s3t3WGYfTbNghjo7QF1hk0ytodpnz9e+24ijBRMaQmH8kPujuRKz/ODjj07zWH7l2e3b xF1qT1u61AI/5hIO6wMVT6VGNdiFNkZSjp8RnQurB9Sq0gVe12oxGxpz5VuNA0P/o9m8 b3XFkfWjDg8UumE0itkgQtVHqvOz5FSPmAh+YlUtDQMA8JvKWU03IjGIfh5OVpY6lVkc jz75FdG/3lPU195J5Gh3CqQyFYrS1XVDe88Vzj/qVyij4ytelY5itufbr80BXcwZKxn0 9cGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H08UXXHZ; 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 3si32743364plq.138.2019.01.28.09.35.21; Mon, 28 Jan 2019 09:35:21 -0800 (PST) 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 header.s=google header.b=H08UXXHZ; 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 S1729900AbfA1Pz3 (ORCPT + 31 others); Mon, 28 Jan 2019 10:55:29 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40965 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729881AbfA1PzY (ORCPT ); Mon, 28 Jan 2019 10:55:24 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so18589966wrs.8 for ; Mon, 28 Jan 2019 07:55:22 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=lZsyg31nN3cTqKBQ+cnJv/eVAHpsVh0TDVW8eJ9YX1U=; b=H08UXXHZSo6EQbLRUZaDJa+u695P9tPKYYCyWyb1Sk5F35f1SNHRnD/TEMkd0ze3iB Q+/TtKyEyXXnUrRUF49uuQXdrphkZSAFqlv+xBzTC41xskHXGABFZ5woc2c03yrkoJkE PLgHsylS620TRUE1dUS7QjSyaMrNx2p9fltJE= 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:mime-version:content-transfer-encoding; bh=lZsyg31nN3cTqKBQ+cnJv/eVAHpsVh0TDVW8eJ9YX1U=; b=PJ8YDATbTCDFrVQYrS1xGbY0PIZgx4gFVQozWsmeC2l7YFQBeTzwThi+injTdB9iBR xsOjZ6kNprqxjfQODCpFmEeoaqtq5OqQ08NsPHh+TV9IIe1oqvxMfyUmLnBqvnlrhglA Mc3rTcwkxeahNOJ+3ZqIhvMzaA+W1Zgfrv5stDMozfA2mGgYU04uliIoHq3u2cd30BHU 236VWtzj9PulLViEAOEdYcUP/Xp1aQ5HPjHkC2OJsBqW1WOSoJYsO6pYAnB2vxkb+rjo 9O+qJS/lTTlBddit3/vQ/2N6aQkL9384stzBpVtfqxAdcNj09xVnVX34A68AtFY+MnaF Lx/A== X-Gm-Message-State: AJcUukexn1WXeX1QBLKjHeV2Px5SK1iJonlZZVUj3Ibu2cqfFOuFNlpI 08THLzjZaAx4aTdicSacBsq/jT1WILE= X-Received: by 2002:a5d:40c1:: with SMTP id b1mr23293116wrq.133.1548690921964; Mon, 28 Jan 2019 07:55:21 -0800 (PST) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id p6sm145140485wrx.50.2019.01.28.07.55.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 07:55:21 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 12/13] nvmem: core: Fix device reference leak Date: Mon, 28 Jan 2019 15:55:05 +0000 Message-Id: <20190128155506.25566-13-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> References: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alban Bedel __nvmem_device_get() make use of bus_find_device() to get the relevant device and this function increase the reference count of the device found, however this is not accounted for anywhere. Fix __nvmem_device_get() and __nvmem_device_put() to properly release this reference count. Signed-off-by: Alban Bedel Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 1752768dd2d2..5400017ef616 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -811,6 +811,7 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, "could not increase module refcount for cell %s\n", nvmem_dev_name(nvmem)); + put_device(&nvmem->dev); return ERR_PTR(-EINVAL); } @@ -821,6 +822,7 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, static void __nvmem_device_put(struct nvmem_device *nvmem) { + put_device(&nvmem->dev); module_put(nvmem->owner); kref_put(&nvmem->refcnt, nvmem_device_release); }