Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754673AbcCSNbY (ORCPT ); Sat, 19 Mar 2016 09:31:24 -0400 Received: from mleia.com ([178.79.152.223]:49224 "EHLO mail.mleia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754486AbcCSNbX (ORCPT ); Sat, 19 Mar 2016 09:31:23 -0400 From: Vladimir Zapolskiy To: Bjorn Andersson , Ohad Ben-Cohen , Ludovic Barre Cc: Lee Jones , linux-kernel@vger.kernel.org Subject: [PATCH] remoteproc: st: fix check of syscon_regmap_lookup_by_phandle() return value Date: Sat, 19 Mar 2016 15:31:10 +0200 Message-Id: <1458394270-21938-1-git-send-email-vz@mleia.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-49551924 X-CRM114-CacheID: sfid-20160319_133517_313657_E544F9E9 X-CRM114-Status: GOOD ( 11.37 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 933 Lines: 27 syscon_regmap_lookup_by_phandle() returns either a valid pointer to struct regmap or ERR_PTR() error value, check for NULL is invalid and on error path may lead to oops, the change corrects the check. Signed-off-by: Vladimir Zapolskiy --- drivers/remoteproc/st_remoteproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index 6bb04d4..6f056ca 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -189,9 +189,9 @@ static int st_rproc_parse_dt(struct platform_device *pdev) } ddata->boot_base = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); - if (!ddata->boot_base) { + if (IS_ERR(ddata->boot_base)) { dev_err(dev, "Boot base not found\n"); - return -EINVAL; + return PTR_ERR(ddata->boot_base); } err = of_property_read_u32_index(np, "st,syscfg", 1, -- 2.1.4