Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1089176imi; Fri, 1 Jul 2022 02:53:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uvd9gwAtHCKEKP0VTJUWvI7/I6ommXbdVQ3gVkLRlf1gVaxBDKxZw9+BMi3cSsZd+jODgS X-Received: by 2002:a17:906:c152:b0:726:3226:2e61 with SMTP id dp18-20020a170906c15200b0072632262e61mr13780698ejc.122.1656669208993; Fri, 01 Jul 2022 02:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656669208; cv=none; d=google.com; s=arc-20160816; b=uaSklI1ZAWQcOl8AHju0hfrk+6trvkwKhP2TXYD3Wd1sqkfAOZFTqI5/xy92Uce2O5 ok3W0SWmfvez3Rw7j5BJCIUGyVsWXro4pl5A8bPh/dCzUBq1DqOOTRkP0JrEybNiKhY2 kHKtgjTOw3Y49Rp61e14kttCYmrooIBrqZHE7KYqP9I+wLVmrgtuoIOnEZej1/cX0KhH ogjrBGCZaPwpSAz/Mn7xpv6BJmvRW+6WLijJkxdozCi+JUmWOOqMppSF7ZEI09/ietTb RuqJKqWWMLanb4z7T4rzWSz4ylCgeZjOX/sHdF+at/AMs8ibjxMuFImGDC/ia5+hWUrm 4hFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fBr5qtPr6s8jT00j0Ax+3mYJ+4ZERsCHkNnYyU9Afj4=; b=BY2Gk0bxgKU8xb2HWe62KfFr22vpG20nkOVI33/vW14OkxJWzDipuaVmSkgs+v1iUt 2IaeFEgKK5Tu/9HxymrL0U5pL2MhJ9Hx17ZLIiXu7h6NvrdVohjTTAZHdVputrTbKc7f FUglRqI/dfAl1X+Qu80LZmzfcf0AlIcRP5xqBLZsIZFzWcAkgpWCCmLW5yJrQg0shwdn lWwzHMLoKjRmBSps1Rrpgo68HxZXnMzP20b6TykL1KvOOqYgTos9Vht1fAjHm73l3BtP /WGUILaL1brmOqOHImj+5ubyGrhzcXT83+xZVl5LPg+1rqdAI/g83IIh8SnztOKkLlWX XEeQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga28-20020a1709070c1c00b00726abda6121si44335ejc.533.2022.07.01.02.53.03; Fri, 01 Jul 2022 02:53:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232946AbiGAJmT (ORCPT + 99 others); Fri, 1 Jul 2022 05:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236427AbiGAJmR (ORCPT ); Fri, 1 Jul 2022 05:42:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AF2B42ED6 for ; Fri, 1 Jul 2022 02:42:16 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 88662113E; Fri, 1 Jul 2022 02:42:16 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C3113F66F; Fri, 1 Jul 2022 02:42:15 -0700 (PDT) Date: Fri, 1 Jul 2022 10:42:12 +0100 From: Sudeep Holla To: huhai <15815827059@163.com> Cc: cristian.marussi@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, luriwen@kylinos.cn, liuyun01@kylinos.cn, huhai , k2ci Subject: Re: [PATCH] firmware: arm_scpi: Fix error handle when scpi probe failed Message-ID: <20220701094212.snsnbdjc7hia5oti@bogus> References: <20220701061606.151366-1-15815827059@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220701061606.151366-1-15815827059@163.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,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 On Fri, Jul 01, 2022 at 02:16:06PM +0800, huhai wrote: > From: huhai > > When scpi probe fails, do not just return the error code, but also reset > the global scpi_info to NULL, otherwise scpi_hwmon_probe() may get a UAF > and cause panic: > Interesting, which platform are you using this on ? SCPI is deprecated for a while, please switch to SCMI which is well maintained both in terms of specification and support in the kernel. I also assume this is 64-bit platform, so I don't want you to get stuck in future because of lack of some feature in SCPI. Please see if you can migrate to SCMI. > scpi_protocol FTSC0001:00: incorrect or no SCP firmware found > ... ... > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 > Mem abort info: > [...] I think we don't see to make it complex. Can't it be as simple as: Regards, Sudeep -->8 diff --git i/drivers/firmware/arm_scpi.c w/drivers/firmware/arm_scpi.c index ddf0b9ff9e15..6fa1a5b193b8 100644 --- i/drivers/firmware/arm_scpi.c +++ w/drivers/firmware/arm_scpi.c @@ -799,7 +799,7 @@ static struct scpi_ops scpi_ops = { struct scpi_ops *get_scpi_ops(void) { - return scpi_info ? scpi_info->scpi_ops : NULL; + return scpi_info && scpi_info->scpi_ops ? scpi_info->scpi_ops : NULL; } EXPORT_SYMBOL_GPL(get_scpi_ops);