Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2851290imu; Sun, 6 Jan 2019 11:33:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xEyUhztpSwICTYdYzCnDDI9aotuzBPqXUT1iy5wOLQkcGJWygpWBIw4aLI1W1nXo6WVCK X-Received: by 2002:a63:b105:: with SMTP id r5mr8572396pgf.442.1546803182119; Sun, 06 Jan 2019 11:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546803182; cv=none; d=google.com; s=arc-20160816; b=eelis26JG0H5RDT6DG1vs42SmUDWanEuDjtQp9C0AVaX0N9FhN9yCGyABBxM9f8d0q HwGQ8l72+6hu8UOhKrdZAm9W8UfHnipgMxBUtY1TbynvYbowUAXqGjwI5lngFtpHI7lT 3e45txgOxl58GO6ajN4kZ9IYRA+p/WwMUacbEkRz21icE0e50xB2Z9gUUvGI/JANMjtf Cg3/Yq0zr8QkYEurLmfQcsWZOIki4SIbrrNWMuGxxiZ0MSFT7bk067WglygsxEsctEO+ XmGigcNh12MfpQvLZUhKALA4hD9WY4P5D5o0NmNoIUNaYtuP9PwVcOUSQGGKFmEsAe+N AXbw== 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; bh=nHwY0oqP3fkEU3yNQpXf7ujPBz044gMf7xVSecnSlSM=; b=Ktkt+tKqsZcSvIMEqhJRExpj+97HcRG9WdAkI1PGeEaxBM1fab84MZwp0o+b5AbflL CLKy9wUGbPJBgfwrQViQCJ8KObi7etseQgntvDG/m3h6Dt3uBoNm8p0R54quaGg+ASCF CJMbSZnUBUfJuqkbPHr7Zs+AMuPS/6UN4hwIwA2/vZ0scKJtehYNKTVO8CgICbH7xJjG AtnJfpajCn1bZuYX7mwtMrpcuIZFwUTTwlNJrD31tAcTwyyW6ak9VtLUYx3zZZouZuuR yXng+VuACq+XmlfEQXkTjPW2hNJwWfH3IeIIGUYZnu/M0q6IxZkizV4JOaB37wIb11rM xBEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si42649176pln.368.2019.01.06.11.32.47; Sun, 06 Jan 2019 11:33:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbfAFT3R (ORCPT + 99 others); Sun, 6 Jan 2019 14:29:17 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:36057 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfAFT3R (ORCPT ); Sun, 6 Jan 2019 14:29:17 -0500 Received: from localhost.localdomain (unknown [IPv6:2a02:8108:4840:8f74:143e:fcd5:beb7:2140]) (Authenticated sender: albeu) by smtp3-g21.free.fr (Postfix) with ESMTPA id A213813F879; Sun, 6 Jan 2019 20:29:09 +0100 (CET) From: Alban Bedel To: Srinivas Kandagatla Cc: linux-kernel@vger.kernel.org, Alban Bedel Subject: [PATCH 7/8] nvmem: core: Fix device reference leak Date: Sun, 6 Jan 2019 20:28:19 +0100 Message-Id: <20190106192820.12558-8-albeu@free.fr> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190106192820.12558-1-albeu@free.fr> References: <20190106192820.12558-1-albeu@free.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __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 --- drivers/nvmem/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 2fa97b373601..176fe72f4eb5 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); } -- 2.19.1