From patchwork Wed Jun 27 05:59:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 935313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ragnatech.se Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Fsqq3RDSz9s0n for ; Wed, 27 Jun 2018 16:06:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753023AbeF0GGp (ORCPT ); Wed, 27 Jun 2018 02:06:45 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:5285 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752888AbeF0GGo (ORCPT ); Wed, 27 Jun 2018 02:06:44 -0400 X-Greylist: delayed 363 seconds by postgrey-1.27 at vger.kernel.org; Wed, 27 Jun 2018 02:06:43 EDT X-Halon-ID: 4cdb6e40-79cf-11e8-a514-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 4cdb6e40-79cf-11e8-a514-005056917a89; Wed, 27 Jun 2018 08:00:22 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH] pinctrl: sh-pfc: fix a null pointer dereference of drive strength information Date: Wed, 27 Jun 2018 07:59:59 +0200 Message-Id: <20180627055959.21001-1-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Not all SoCs describes the drive strength registers. When reading the sysfs pinconf-pins file on such a SoC this results in a null pointer dereference. Protect against this dereference and allow reading of the pinconf-pins by adding a check if the drive strength registers are described or not. Signed-off-by: Niklas Söderlund --- drivers/pinctrl/sh-pfc/pinctrl.c | 3 +++ 1 file changed, 3 insertions(+) --- Hi Geert, This was found on the Eagle board and is based on the latest renesas/devel branch. Regards, Niklas diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 654dc20e171b9363..ef837676d0312e8d 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -483,6 +483,9 @@ static u32 sh_pfc_pinconf_find_drive_strength_reg(struct sh_pfc *pfc, const struct pinmux_drive_reg *reg; unsigned int i; + if (!pfc->info->drive_regs) + return 0; + for (reg = pfc->info->drive_regs; reg->reg; ++reg) { for (i = 0; i < ARRAY_SIZE(reg->fields); ++i) { field = ®->fields[i];