Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1025600ybe; Wed, 4 Sep 2019 11:20:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh8yuh7GvQJTCyAozBcBB7xKNiPs7+d/Ilj0GtruNSHD1LUVd7WVoncWXU32F3i+hErQjY X-Received: by 2002:a17:902:581:: with SMTP id f1mr41475237plf.246.1567621208552; Wed, 04 Sep 2019 11:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621208; cv=none; d=google.com; s=arc-20160816; b=Bfjyu+JYVq0C3xcSHNTYD+5kbzEqVP/S1J0Un3+pNIEUGpLytujfGfAx6WKkl4ZpCL TRlo4xm34uvFfz+Fa18lz76uFoGvJbB2a1WWIwhMLP1LJ+JX38Qi+dX62nnA77omvnwq zuaVb0T3xlkQQQypieu+yQuW8X2VaBh+63CoJmGUeF0gmZicVARMnsONEkG+1YI582QZ erWOB3d9khQdwARP558PpJXw561hHJhloarwuTa9fErFU4fqabfyY+KQI0pYFk77cQIs T7wP2XudrGGQHFwbVGG3X7DkCJS05e5DbhsozuELpi8cpUo2C6Jshn8f88KgcFtBFvyg UXGw== 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=knRBdDauQMAbIDbxKzVzEpKoyionL5Zvd5OPnG4DyLQ=; b=XVKAvkMSXi9G+3G2j1I4RBOv149RT0A+0usxRpQjtCgQPt3gnE7f8PkuaYxtdrWTHz jrUGn+2BYMAEF/kp8D72SMljUblVkdZCQJE90pIV4YKlD4hqB7buqnjlruRhJMnuNs8C +X3FNu9lMJYD7g5cEQFAPnZsvr53nig/MhMYQMygZH/QfgJJ0YVtb561H2X/H0UT1MRj lDv5L0A4b56Uqcyh/Srv2zbZZ651FxTz2NXzj1h55ODNKKk0H7yjbrjn/ZlKJ8TRCjtK Jdb63AS5SEsgoDGjlj3H++kpZ0L5M9rT8nWg3z6fdwu7kIr86vg4Vdx52Z1nAitm+fnv QvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k1qikXAh; 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 m4si2849313pjs.62.2019.09.04.11.19.53; Wed, 04 Sep 2019 11:20:08 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k1qikXAh; 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 S2390253AbfIDSLS (ORCPT + 99 others); Wed, 4 Sep 2019 14:11:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:55224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389078AbfIDSLQ (ORCPT ); Wed, 4 Sep 2019 14:11:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4937B2087E; Wed, 4 Sep 2019 18:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620675; bh=6VocBX/cUeMQovf54r30/HgPsxfG/keOsg+hSKLsjPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1qikXAhjY9nwSoQpREVg1orzn5241AD9Skcu9NCUG2lGZ2MOyD2vojhNVRhfgLU6 tG1UcxkLSv89zyEFLLA8CpW9UYU6x5U2FAonH2p+QhBKmdh8iuN5UKBJKUD3Xr/AYJ x9tH5Ja+F9DOjxTBJqXx9cQGs1mpQd5BY2jHjZ+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Chevallier , Antoine Tenart , Grygorii Strashko , "David S. Miller" Subject: [PATCH 5.2 051/143] net: cpsw: fix NULL pointer exception in the probe error path Date: Wed, 4 Sep 2019 19:53:14 +0200 Message-Id: <20190904175316.065876752@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Antoine Tenart [ Upstream commit 2d683eaaeeb9d33d23674ae635e0ef1448523d18 ] In certain cases when the probe function fails the error path calls cpsw_remove_dt() before calling platform_set_drvdata(). This is an issue as cpsw_remove_dt() uses platform_get_drvdata() to retrieve the cpsw_common data and leds to a NULL pointer exception. This patches fixes it by calling platform_set_drvdata() earlier in the probe. Fixes: 83a8471ba255 ("net: ethernet: ti: cpsw: refactor probe to group common hw initialization") Reported-by: Maxime Chevallier Signed-off-by: Antoine Tenart Reviewed-by: Grygorii Strashko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ti/cpsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2372,6 +2372,7 @@ static int cpsw_probe(struct platform_de if (!cpsw) return -ENOMEM; + platform_set_drvdata(pdev, cpsw); cpsw->dev = dev; mode = devm_gpiod_get_array_optional(dev, "mode", GPIOD_OUT_LOW); @@ -2476,7 +2477,6 @@ static int cpsw_probe(struct platform_de goto clean_cpts; } - platform_set_drvdata(pdev, ndev); priv = netdev_priv(ndev); priv->cpsw = cpsw; priv->ndev = ndev;