From patchwork Mon Jan 28 15:55:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 156762 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3582062jaa; Mon, 28 Jan 2019 07:55:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN52NJ9UIL0QCutqM+CMpzBOC4fmBsGNc5AKpR1l28DPCD4O9rbDrEy4+bCGSAXqyMlaa4Yh X-Received: by 2002:a17:902:4601:: with SMTP id o1mr22275805pld.243.1548690927286; Mon, 28 Jan 2019 07:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548690927; cv=none; d=google.com; s=arc-20160816; b=RZ0hHOYWyWcI7DDCecxjfa+cvlpmIyG5bAjRAsM5SI4/C5UNdTqb+pvM1m9sXP+4hL UkVJV1bAruqY+GUW9dN33QgWnQUkDRqReLNiMFasg87P3BCJguKAVPz50dbvS9PD27gT nNqy67K6tvRLPrraEqmapP1rMOOLdgF5khjYXKrmRoQKI3R5Ub0hBzhd2vxuvYVWrnNv pnnZzxiYDPXad32E1v6fLp6B93XmBST3PICLAg+UlbnMkc+A0MVYzRj9t+IwNYFgoL7E SDEOLG9NiqNdwk0D78Yz0G/7Zo7m61TQOmyRlChnSWMsxtT8MYUuwWQ+cY8JtmRbEF26 U4Wg== 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=e0Ha4ellaoNOp/hRaJJ64zG2xd/bafkpJFLNPc8fabM=; b=K4oTB0Wh8hsKgnuhYGK3GUQmlXjO0gMNOjGfKiJpEK43fWlFhsJrviGcFldoUYhmsI DBiR5j5lkTCCTRSlmWhM42Y01WGYJ4KAYrLUTvOQkCscv5kDqCh39/U6XqwJgJ1E7SUm ++BGB6o26RXmS0k3ZqC4fN0voAl7nspjUthrjEFhYp2nI9nx00ZGI3XDMA7g6B0+dozx pPzwb+2IdXer8GSLNP6UvJAmWfpgDB6srauWU/G3DA4VXNalWd9XP1mLSMXbQdxz3kIP nkwnWwUMOxtgWf/vmlz7rORmOGxFn9ZvXs899bezaIP4qb/K/e9HC18zvTrDPTAGLQsn X+ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fjDvN5g9; 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 j186si172374pfb.174.2019.01.28.07.55.27; Mon, 28 Jan 2019 07:55:27 -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=fjDvN5g9; 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 S1729439AbfA1PzZ (ORCPT + 31 others); Mon, 28 Jan 2019 10:55:25 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40335 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728859AbfA1PzW (ORCPT ); Mon, 28 Jan 2019 10:55:22 -0500 Received: by mail-wr1-f68.google.com with SMTP id p4so18623901wrt.7 for ; Mon, 28 Jan 2019 07:55:21 -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=e0Ha4ellaoNOp/hRaJJ64zG2xd/bafkpJFLNPc8fabM=; b=fjDvN5g9fjipqa2VAqDp3/6TPI+kGIIQBdBnots0pBJug2WXIXVM5VihE4JUIxDF5U mMBzLvPto83PARanyrApdIIFfNbAQxauJGfUn0j514Vpl8AF9ZlWsVHNh7l+WZc3zuVc xPxdsHguQYtEQcYx6fVlSrdUsPV2mrhtoX+Cc= 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=e0Ha4ellaoNOp/hRaJJ64zG2xd/bafkpJFLNPc8fabM=; b=Cd8Jba+WCWh+gkC4tWfq6WZQ01NTth/dSajy4zaSrqLW3PjNcMMdO1ZVQ/lik8vIyD xyI8DzfqQUPsNrVguWOa7moE1LmgOorFSb2EpJruU3vlRzwf5QdymvtXRBNsITwuKFnb UY5hs1v2XR7wtm3qB+7+ejKy9e3ZpXJa1w3vG8Drj159DFnHBscILqrA3tkHxCNs9UTK SvZpLcCW958PUawKnELXU17zIQ3eWRKXMV5eJ/X0mWKiH4GSjFf+6eEm32cO6SNmc4Kx PlPDqj2Phzg3Wp6KSy0/2x5CCKOihHWawiYDaYEqSIgot/8vxTGlXEB5qRFEIfQpKaAA /YXw== X-Gm-Message-State: AJcUukfxJD0+ExvrGwziZq8AjRnO+v1cvLJD75mY9S7pQQNOeY5tsTvE 2HTLZgcMyZOQ/35d7n/rkzXDpyVhHAU= X-Received: by 2002:a5d:4f10:: with SMTP id c16mr22937298wru.177.1548690920879; Mon, 28 Jan 2019 07:55:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 07:55:19 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 11/13] nvmem: core: Always reference the device returned by nvmem_device_get() Date: Mon, 28 Jan 2019 15:55:04 +0000 Message-Id: <20190128155506.25566-12-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 In nvmem_device_get(), when the device lookup fails with DT it currently fallback on nvmem_find() which is wrong for two reasons. First nvmem_find() return NULL when nothing is found instead of an ERR_PTR. But nvmem_find() also just lookup the device, it doesn't reference the module and increment the reference count like it is done in the DT path. To fix this we replace the call to nvmem_find() with a call to __nvmem_device_get() which does all the referencing and return a proper ERR_PTR in case of error. Signed-off-by: Alban Bedel Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index a749a5cb0a4e..1752768dd2d2 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -874,7 +874,7 @@ struct nvmem_device *nvmem_device_get(struct device *dev, const char *dev_name) } - return nvmem_find(dev_name); + return __nvmem_device_get(NULL, dev_name); } EXPORT_SYMBOL_GPL(nvmem_device_get);