From patchwork Sat Oct 22 07:22:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1095768wrr; Sat, 22 Oct 2022 01:03:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56x73+F0XRXQhYPXGJUL60pRgfiZLaba3//Ps7s2fPFvjn/20Xe/tTyAwKZn4PCD4k8PdN X-Received: by 2002:a63:285:0:b0:46e:9da4:df71 with SMTP id 127-20020a630285000000b0046e9da4df71mr10106180pgc.564.1666425808579; Sat, 22 Oct 2022 01:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425808; cv=none; d=google.com; s=arc-20160816; b=Z9QRiy+G+GO+HjhVnvxkWkNflddMsi8cfxEUi3qb9WlVesAQdYt50MNXZLyGxdF7Y8 0Ul13BesFYnlN3Oy/rEf5jRMoEOHzLl0QMIvRPCbC+V9v9HPraSMwB1M1TA7i2PnadZl 16zZW5DZ4eme15ND4Wk9wDLOIQhs8lPuI6jMGDc1OHPqT+Sj6uA4VRjWFf456kCDDq5Q ppiykw7eHhyXvozn1DYKsarU26vu1v7QsY1wfEMb4B2w08luQhRKyQFB1O2rBuasQHmX aHmFO9vhZ9xqNtOItAS3+9IHlggnnYaSmbK+npWv7K8w8cGNQgqH77/8ZqG5DlxSozqN rx6g== 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=AW+NyJ0F48ftx91VRFw+qXnvt5ovAtiBxMdRFSdVWqo=; b=QxbygZwDefr6bd6GF3pMey2dS5uUrhlH4/PFUlkN5HN1Mk6Y7J2Fx/xBeHhfVeALRv zk9PTqWVan/KFcf245kpQ5zHCTtkBwJlmbqXIIXsQdHBfCM5nT0LZGDpVOizg++waMed 4td/+0Qg6elbdVhDcPIESC5P3BiqoA4If6Xxigj/LoErFGcbpi1BB9NqQ+lSJPeXKvQ8 68KtdiRBDRK3f0Dl8MbupSat5wFFmDn96m0R/sybJgP39R0hRJkC6KVTkTcnbyEKorD6 Z4tO1ZgTEiTAms5l7FHf7GDEKp/tnLUdl5FZyq3szvtwW7lAK8JCiW0XUBsnMi2wXky0 o7oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gR/r/+dC"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902b18900b0017f8d9b7e5fsi26070166plr.133.2022.10.22.01.03.15; Sat, 22 Oct 2022 01:03: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gR/r/+dC"; 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 S230150AbiJVIC6 (ORCPT + 99 others); Sat, 22 Oct 2022 04:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbiJVHyn (ORCPT ); Sat, 22 Oct 2022 03:54:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A472CDE7; Sat, 22 Oct 2022 00:47:55 -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 C1158B82E13; Sat, 22 Oct 2022 07:47:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DF63C433C1; Sat, 22 Oct 2022 07:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424827; bh=qubxgJW3yy4v52tdRBQ7C/fWqSRTYb6tebZiHAJIdL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gR/r/+dCvEDeH7zXQm3r1qOKh7VlWIV2G9w53qf87qC4Z3xPEfGj1xbi7mWqes1Il nOSayFLQb3l1ThmkzyVVDVreo+H5xtPP54sPJ0+vObtJwqSQ6JOeM5fDijXIisroyh 9ohnL5Fjht0obMx/6fjVBf+u0ZVkvWRW3MutUx40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheng Wang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.19 290/717] eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address Date: Sat, 22 Oct 2022 09:22:49 +0200 Message-Id: <20221022072504.730256985@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374108636443995?= X-GMAIL-MSGID: =?utf-8?q?1747374108636443995?= From: Zheng Wang [ Upstream commit 12aece8b01507a2d357a1861f470e83621fbb6f2 ] This frees "mac" and tries to display its address as part of the error message on the next line. Swap the order. Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021") Signed-off-by: Zheng Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/sunplus/spl2sw_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c index 3773ce5e12cc..37711331ba0f 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c @@ -248,8 +248,8 @@ static int spl2sw_nvmem_get_mac_address(struct device *dev, struct device_node * /* Check if mac address is valid */ if (!is_valid_ether_addr(mac)) { - kfree(mac); dev_info(dev, "Invalid mac address in nvmem (%pM)!\n", mac); + kfree(mac); return -EINVAL; }