From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D0CCC433EF for ; Fri, 1 Jul 2022 09:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xu+4hRjHOE93rxHIg+P0at4/KqCosND/TBDyJdCVhS4=; b=AYh5RqBjKVpA40 LvWYsrhE2lsobxCdc3t1ytVfAdbfooNik8RaTagn/A6FxbrFFRJGmSnNWtlGA+4+LNB8ow0i2IFQO 0V5FDQjLGpj9nSL9AvSZKco8kjLwxS+KDhIsISMM2gMWrTdu2ypd/jLk2iitJfSPKhTGrJJJHJR5W FU+KcSkjqZaxoJzTlXHdQD6j+NFNwWC4QFiAo78MePJAdd/GREW/POibE4lRrhm5fHy2pHqUt1Uak PhgU/K6HfpQHRPwSKxkdEIbQASOkyzir1Z94B02C+Q5obSFlFugmjB2pK9Oi2MrOGHcVr/bg6uImL awc/CHKZNMB0l5RDQWkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7DAL-003uia-Pi; Fri, 01 Jul 2022 09:42:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7DAI-003uhQ-EN for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 09:42:20 +0000 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-Disposition: inline In-Reply-To: <20220701061606.151366-1-15815827059@163.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220701_024218_564412_934767BF X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel