From patchwork Wed Sep 23 17:37:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 54071 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 0016A22E14 for ; Wed, 23 Sep 2015 17:38:26 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf28411068wic.1 for ; Wed, 23 Sep 2015 10:38:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=c1CtNLRGHRiD1xWjyP+g/QY9Eetx3z+NA79pIqmZ0SA=; b=cuQ0R+NbBl/BblbhmK4iSRcjM3y7pPGXo4KKv6RvB1Y2YywmZMMUt04MkGSVfxjazq NlY/EIB9l/D0MPmib24ZE44eA3JF7xrz8VQKoVbgehB1DlrLwVaf/8U93SH3f4+Cd614 SMb0t7J5eLGgMajXshvKWPXBouBARD4lRotbY0MzlIZrWlEQItmifMaqTCyjbtcGBHfU 2Y+lcsdl9JAbkF02qcnNY1tEVoIx/tNi9hTY6CawT5gCpxLEgHj5K2pvROil5WA+1XTs 4HeI4pZIBqolFjiR7tjvuVm27YAbXnpewxBqzJ2llRLXx1Rpal6vIBc4O/mWfbDRVl1l wiFg== X-Gm-Message-State: ALoCoQmZ4IsavALxyy61fXCTweoNaR0lZ3zZarH4HAiFhQxMNTNis0ZoabBQujWxaNkTLbxSClw6 X-Received: by 10.152.6.201 with SMTP id d9mr5524742laa.6.1443029906255; Wed, 23 Sep 2015 10:38:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.42.209 with SMTP id q200ls125067lfq.72.gmail; Wed, 23 Sep 2015 10:38:26 -0700 (PDT) X-Received: by 10.152.10.4 with SMTP id e4mr12216416lab.79.1443029906093; Wed, 23 Sep 2015 10:38:26 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id a2si4553800lak.102.2015.09.23.10.38.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2015 10:38:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagj9 with SMTP id j9so59827862lag.2 for ; Wed, 23 Sep 2015 10:38:26 -0700 (PDT) X-Received: by 10.112.130.70 with SMTP id oc6mr12369065lbb.32.1443029905861; Wed, 23 Sep 2015 10:38:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp28640lbq; Wed, 23 Sep 2015 10:38:24 -0700 (PDT) X-Received: by 10.68.192.70 with SMTP id he6mr38748648pbc.157.1443029904835; Wed, 23 Sep 2015 10:38:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si12031304pbu.198.2015.09.23.10.38.24; Wed, 23 Sep 2015 10:38:24 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756512AbbIWRiD (ORCPT + 30 others); Wed, 23 Sep 2015 13:38:03 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:32951 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756112AbbIWRg6 (ORCPT ); Wed, 23 Sep 2015 13:36:58 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t8NHavBW022355; Wed, 23 Sep 2015 12:36:57 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8NHavX3030133; Wed, 23 Sep 2015 12:36:57 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Wed, 23 Sep 2015 12:36:57 -0500 Received: from ula0868495.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8NHarOW021888; Wed, 23 Sep 2015 12:36:56 -0500 From: Murali Karicheri To: , , , , , CC: Subject: [PATCH 5/7] net: netcp: check for interface handle in netcp_module_probe() Date: Wed, 23 Sep 2015 13:37:09 -0400 Message-ID: <1443029831-22035-6-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443029831-22035-1-git-send-email-m-karicheri2@ti.com> References: <1443029831-22035-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently netcp_module_probe() doesn't check the return value of of_parse_phandle() that points to the interface data for the module and then pass the node ptr to the module which is incorrect. Check for return value and free the intf_modpriv if there is error. Signed-off-by: Murali Karicheri --- drivers/net/ethernet/ti/netcp_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c index 97e2629..d39dce3 100644 --- a/drivers/net/ethernet/ti/netcp_core.c +++ b/drivers/net/ethernet/ti/netcp_core.c @@ -299,6 +299,11 @@ static int netcp_module_probe(struct netcp_device *netcp_device, interface = of_parse_phandle(netcp_intf->node_interface, module->name, 0); + if (!interface) { + devm_kfree(dev, intf_modpriv); + continue; + } + intf_modpriv->netcp_priv = netcp_intf; intf_modpriv->netcp_module = module; list_add_tail(&intf_modpriv->intf_list,