From patchwork Fri Mar 15 16:57:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10855307 X-Patchwork-Delegate: andy.shevchenko@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E77A26C2 for ; Fri, 15 Mar 2019 16:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8CB2A199 for ; Fri, 15 Mar 2019 16:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C28982A196; Fri, 15 Mar 2019 16:59:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77B622A196 for ; Fri, 15 Mar 2019 16:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729652AbfCOQ6H (ORCPT ); Fri, 15 Mar 2019 12:58:07 -0400 Received: from mga17.intel.com ([192.55.52.151]:39353 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbfCOQ6H (ORCPT ); Fri, 15 Mar 2019 12:58:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2019 09:58:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,482,1544515200"; d="scan'208";a="155397166" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 15 Mar 2019 09:58:03 -0700 From: Heikki Krogerus To: Hans de Goede Cc: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH 01/12] software node: Prevent potential NULL Pointer Dereference Date: Fri, 15 Mar 2019 19:57:49 +0300 Message-Id: <20190315165800.5058-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190315165800.5058-1-heikki.krogerus@linux.intel.com> References: <20190315165800.5058-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Software nodes are not forced to have device properties. Adding check to property_entries_dup() to make it possible to create software nodes that don't have any properties. Signed-off-by: Heikki Krogerus --- drivers/base/swnode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 1fad9291f6aa..3a50a8edd3d3 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -383,6 +383,9 @@ property_entries_dup(const struct property_entry *properties) int i, n = 0; int ret; + if (!properties) + return NULL; + while (properties[n].name) n++;