Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3482707imu; Sun, 11 Nov 2018 16:07:06 -0800 (PST) X-Google-Smtp-Source: AJdET5fQlrJHm8PxnegayK37lKUiUCK4FRBdYH3xT2Nrg7nqP5R/hqx6dL3Kxw2jChCql+JsLPWo X-Received: by 2002:a63:4b60:: with SMTP id k32mr15409796pgl.186.1541981226094; Sun, 11 Nov 2018 16:07:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981226; cv=none; d=google.com; s=arc-20160816; b=CHUMzFBWviqsCrLtlezRwTk91z5Q47jh2F+ApC/2DlBWcHa5o8G+PNvxRB8Uy5OXnv T9Trvzn97h7XYEm+6VkrYthOQrSJIv6GdtWnVJ8BvAfGfzQdK3zCkoYsD8vuZ4oAkbSa 34nJ38Vq3lCZv1PaJweWA7cWMGFi3DanIB45caPk8emTPbQaADQPpn+QdZGKE/Xwqx6A Or2X1AQZGf2zPcUVZmcbyqNDfcXPXHi0v31xowIC2yaALM4nQFYRxgAu91B8Oy3WeyFb UBKsyD9BfYkW/xPyWHTvLe7+h++gHvoYBuRAs53SX+75kKxf1dVTIhiimGcnwKPBdxx9 my5Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VA4EZEy3ArLeXIhL05oWYFzb1KYEvPNqBv0v3JgbJX0=; b=sS3WQ9aQc99szQOeuXgOyNMs5E7VW6m7Wkhyj8v4jXRq4Y2iX1dbrfhxL/3FRc+oAz a5TPCzIeDxoB/c9vGeS1N6+IiV545Mu9WEYs31k8TQ72soXJYsWMnkLAPHd4wHEATst6 v/6Z3zt61ghXd7x3Z8hnQGQEOmnlVo9jAWBHNDH51PBMYT2ShVw5Q/4l+hgfSihmWKQ/ bPBiO1aZ6R2P1Z1BuMpAsky4Ebv/wNtbW4QtH+sj/fSdWVNlWDcqSYK9OprrGAtUdWT5 6CarLKLIeBm9gYdsBJwMS6glpU5in2lb2NN3oxYKHNO4yHof8zQQds9Adil7IprI9VOX NyFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uREpnTk8; 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 69si15132501pgd.290.2018.11.11.16.06.51; Sun, 11 Nov 2018 16:07:06 -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=@kernel.org header.s=default header.b=uREpnTk8; 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 S1732093AbeKLJzp (ORCPT + 99 others); Mon, 12 Nov 2018 04:55:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:34452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731934AbeKLIRo (ORCPT ); Mon, 12 Nov 2018 03:17:44 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9158221508; Sun, 11 Nov 2018 22:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975268; bh=qWjM+ajTMzFznb2L0ALdOhbCxFV+1suH5y6U04Da/rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uREpnTk8fDxM21nDKSEHzKeCjDf6YYKG48doBwJE1iomSu0nUM5wMmW6NVpGfojNZ 6yqFh7uvnmirxJVozi96sCJkzlrr/ZO1h94SZcjg9XFtQ0Q7/ZiqqX71/mbGMLxGpl KQr6DcGn87nPe+RqyyejeBmm6Y4K5JHPxq/aCLJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bartosz Golaszewski , Srinivas Kandagatla , Sasha Levin Subject: [PATCH 4.19 164/361] nvmem: check the return value of nvmem_add_cells() Date: Sun, 11 Nov 2018 14:18:31 -0800 Message-Id: <20181111221643.432526195@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/nvmem/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -516,11 +516,17 @@ struct nvmem_device *nvmem_register(cons 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: