Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170296imd; Wed, 31 Oct 2018 16:44:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5e3qgdPj2w+1k9IiTefmGWC+AHgC9TWPVXUzecbvPIyiOAoblATwBmrHsMMYYdtkJic8RQJ X-Received: by 2002:a17:902:f096:: with SMTP id go22mr5434320plb.235.1541029457130; Wed, 31 Oct 2018 16:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029457; cv=none; d=google.com; s=arc-20160816; b=p0XwcQyDFC2oySsgwnmsA6Lj7iiYw/11qzk7kKm1WvWMlIFbckXjJTvIw1EVeaRLWs TbrkVspTHMMgx8/N6zD5cOBKZEsOyvJtHtbZVu83q/A+DirdD8ZcAPo4Fz1McmnaerDJ yKhwCtv5Y5bCfPDWoggXKyazmO6XS90MlY8Ob4hZOxopUh+kTdiFL65lKxk3Nq/dYSbg gYrmpoT1mNbZe++Zs5Jyg0fNweklwRkZp39PCdP0kpe9UQYJtFzeTA9Y0F+ID2BT+P7T pR+GukKqIwqRUO4YthDxJmk9YJiyux6AdqKeQNk/P5ZxEQgT3J6HiaeiadE7s7YguthE DpZA== 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; bh=QlW9LURHdLJNCdsQa9ucRUOi52t5RVMukNI2cWH6gV4=; b=cPCQZ7YtvP4aVdcv4a9A3Z72pQIsQ/zmhasGQz6osDRpSqrDMe+ekognpPbuKX9iev xuPLJ3XOt/NhThyck0fg5Sf+slix66vdbiHjM4nACDq3TTQcAEp46OhaZFZ1rKGSCnYO 5ViXcK+70ZXvRTAvQwdxbgVQ0xotTA27wS/kKOngI9lLF6jDUcGjbjBwFfMtIsRz5ySl 9kaQctDVDZGynhN5BabheAf0C80glRSaK7m3HSxrADQtpTMiqNMGpcbsD3C8Sizekz6k HxKA7nkljBNJi3bJIB5se1Bgg6U23hhdBSrwm9bn+IE9RhJCXeJVyG8BHo5zMW3Q/+N/ 3hWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YWige8wr; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3-v6si4917330pgg.413.2018.10.31.16.44.02; Wed, 31 Oct 2018 16:44:17 -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=@kernel.org header.s=default header.b=YWige8wr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729088AbeKAIHm (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:55680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbeKAIHl (ORCPT ); Thu, 1 Nov 2018 04:07:41 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE03120821; Wed, 31 Oct 2018 23:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027250; bh=2u9N2z5t4ZTRPc/Yr1WHTsSxUZCkNrie02SwsGBTvBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YWige8wrrsnJ49o6/fYDBYpraPNOOelnlyFQ9ftfrNCbuh7IepF0fMCaMOQTx7Lw9 bvDX7suSvbfuFPRPkQemxLnMz4RBfpI9IJrMK2SejN+UsXHZ4cNz/bzxmAb6UmN8rj Ahi0gAh0WeECE6bGLK5Rb3xpjcyI/GvNyEkNbygI= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bartosz Golaszewski , Srinivas Kandagatla , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 120/146] nvmem: check the return value of nvmem_add_cells() Date: Wed, 31 Oct 2018 19:05:15 -0400 Message-Id: <20181031230541.28822-120-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski [ Upstream commit fa72d847d68d7833b77a4bef944cf2c5baf56f49 ] This function can fail so check its return value in nvmem_register() and act accordingly. Signed-off-by: Bartosz Golaszewski Signed-off-by: Srinivas Kandagatla Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/nvmem/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index aa1657831b70..7c530c88b3fb 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -516,11 +516,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_device_del; } - if (config->cells) - nvmem_add_cells(nvmem, config->cells, config->ncells); + if (config->cells) { + rval = nvmem_add_cells(nvmem, config->cells, config->ncells); + if (rval) + goto err_teardown_compat; + } return nvmem; +err_teardown_compat: + if (config->compat) + device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); err_device_del: device_del(&nvmem->dev); err_put_device: -- 2.17.1