Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3285979pxb; Mon, 18 Apr 2022 21:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnpU6F+4gJMV9lvRVNqWxvGvYTXwDBrHQ+a//nLDZQqFPHq1bPoL6Orl7D4YDd5LSRnI3q X-Received: by 2002:a17:907:9704:b0:6ef:82ff:fa14 with SMTP id jg4-20020a170907970400b006ef82fffa14mr10376878ejc.598.1650343835162; Mon, 18 Apr 2022 21:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650343835; cv=none; d=google.com; s=arc-20160816; b=zdIGYX9WChgidGejC3JL7qdgKjF3+ieXxTpRFlPqOMEDv00lAme0rYKLFmQwDdUghh DcdIFwKNO0gia1nhoxaMeemaGPexBf1zQ2mOoaCTPNNqZ3roECBl5UhKisj4mdlD2wxq /+CK75DkD1Ugru92rWnQeFlj1Q6HhIJLgyvj4/10bs4zpXukGPhr1BvWSx7bu+qFNtiI xsEPiLElMV5+s7HzWHU3kaWsC3pYKnJy73BiFnjQdUnwt5n8Db1OwgBXAWfnrM3j9SGx ctfJOER5oarVITCyyJCbnQklGeuW4MxV8GD4qMaf0CrJdodwyPFun32WPTHgL9P04Zhr 62cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k/RNoICJv6XgZJj5qZ2/c0qkHAhkgXOXH8BEBnKUwHY=; b=SPziFmsCtfD+7xT0Yd0vpkDDBSO+O6RgrO2kwL/zZKfNrLjvVqPI0Gj9eSj5NqpQC2 2p8H370qDqrs+Hfp+RQmuWkInk8rwgZfUJ+uno30Bl7UF2CdDbWJStQnx0z51fn6VRYW 3nUG+Q+ZjN3kNvIL9vL4tPRmFpByjMESIma8cFzmrKI8Ig2yyBf9BQJRaZ2GI8BLGawl kvdFsfyldo1HIa4L6CFGsxbIX4JkrN/xOXGoVHqmZi8Nn0bjk+5do2idZzkwg6U6wtsn xT8o45KBMbQm1TauNP2fAyFVuqz2mwXfAV9rp/gDBMJ9n/0ruIF44hzf/bvfpEmGv7ao 5t8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+3Q8AB9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr6-20020a056402222600b00421b6721603si6938795edb.167.2022.04.18.21.50.11; Mon, 18 Apr 2022 21:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+3Q8AB9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239538AbiDRMlq (ORCPT + 99 others); Mon, 18 Apr 2022 08:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239728AbiDRMdW (ORCPT ); Mon, 18 Apr 2022 08:33:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77EA913DCE; Mon, 18 Apr 2022 05:25:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7CAFDB80ED6; Mon, 18 Apr 2022 12:25:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3C4CC385A7; Mon, 18 Apr 2022 12:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284720; bh=8aq8etiejXnzTulB0gCT3uDujb/HFTZyXETxFWIJ2lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+3Q8AB9lg6UMUk1gpEH2LCoPM6CXp1H5QJoQ1Ht+4+tzFtx3ozt6WF0EbyIpaq7/ zl2OzQCx1kqpC0th1xBvkuTucQnGbvzFgSxOMFKACxyNsAISSCbwvw7YUuSp9w7IQe RMaG1P+dQT3KWP9i3Y8eH+3cI8kIKKUxnqCtJqX0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Arnd Bergmann , Bartosz Golaszewski Subject: [PATCH 5.17 205/219] ARM: davinci: da850-evm: Avoid NULL pointer dereference Date: Mon, 18 Apr 2022 14:12:54 +0200 Message-Id: <20220418121212.607071973@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor commit 83a1cde5c74bfb44b49cb2a940d044bb2380f4ea upstream. With newer versions of GCC, there is a panic in da850_evm_config_emac() when booting multi_v5_defconfig in QEMU under the palmetto-bmc machine: Unable to handle kernel NULL pointer dereference at virtual address 00000020 pgd = (ptrval) [00000020] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 5.15.0 #1 Hardware name: Generic DT based system PC is at da850_evm_config_emac+0x1c/0x120 LR is at do_one_initcall+0x50/0x1e0 The emac_pdata pointer in soc_info is NULL because davinci_soc_info only gets populated on davinci machines but da850_evm_config_emac() is called on all machines via device_initcall(). Move the rmii_en assignment below the machine check so that it is only dereferenced when running on a supported SoC. Fixes: bae105879f2f ("davinci: DA850/OMAP-L138 EVM: implement autodetect of RMII PHY") Signed-off-by: Nathan Chancellor Reviewed-by: Arnd Bergmann Reviewed-by: Bartosz Golaszewski Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/YcS4xVWs6bQlQSPC@archlinux-ax161/ Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-davinci/board-da850-evm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -1101,11 +1101,13 @@ static int __init da850_evm_config_emac( int ret; u32 val; struct davinci_soc_info *soc_info = &davinci_soc_info; - u8 rmii_en = soc_info->emac_pdata->rmii_en; + u8 rmii_en; if (!machine_is_davinci_da850_evm()) return 0; + rmii_en = soc_info->emac_pdata->rmii_en; + cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); val = __raw_readl(cfg_chip3_base);