Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp811708rwi; Wed, 19 Oct 2022 03:19:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HAuZiQ9uV74nkqoNPy5uz0ahmOo3uHJKmJdID7BFT83hcyC1Vll4+zKul7q43dEKjDY+b X-Received: by 2002:a17:906:eeca:b0:730:6880:c397 with SMTP id wu10-20020a170906eeca00b007306880c397mr6048607ejb.593.1666174786676; Wed, 19 Oct 2022 03:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174786; cv=none; d=google.com; s=arc-20160816; b=SlaovJOY/PfouFPeeUxtkV033J7NlBLQXa7Js58Hx9qwABGZOGxF3fCKvjhHyYSkTl I+znuzoqXvNf/9jmOVHsLQI3KltHd5UJRU/ZBxY5pCOXe+j06c5Rr7WCP3m1EtGF/5Pv kiFb5igny6LpB3XZpvAtHclG4aEjFw3GL9l3kteJPxAWb24X0GamV1DmSqKncp6GiKO3 ZCGuOjBbQJpbXYcSfoXjceWDP3Vo2cge5kJPUTO2yoCaqU4qEMSmh2CZk+996AZg26ny 0Aosh4dpMTS5aUrNmFNFg7vdUWGuHn6OSPVzXYgkrRmV4TbawgVYLZQc5tnQ35OC/tzA wWeQ== 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=KZR55gRxc0NIlDMe4ISkDS8oMW6oSpQvv4XE03H1BxA=; b=nBpdtsSoPENS9TFVi40356unvVKk51WXKiQ1yx+mNj1oAoUDtMvlbF6E288lf3b+Wn pUYqfdCeZV6Qs29Y9CHrD2AxFffYB7YHQ4hpqN73zhEMAKATxpGAgfOPaCH34/h2PpHr d/mFdRptI7nLZrmOukmxjUkVk3Z5BORY7H+117z489m4awpR6sqK94VqJZOrMlHMg/6U I/D2pki1y2KuyIF6PlUL6Ir4bR/2cGjB5eBwrzEt72VsP/9vqy0cYStchDxymSjXv1We t3l2dF2750yH3I3OGWCROyUkernEBGJRjTBQbV4OsacvdKAb4YSQy7e3okRELY2FAIVJ kDtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J9inPIEv; 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 f17-20020a0564021e9100b00456e33b69e1si17606534edf.347.2022.10.19.03.19.21; Wed, 19 Oct 2022 03:19:46 -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=J9inPIEv; 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 S232316AbiJSJDq (ORCPT + 99 others); Wed, 19 Oct 2022 05:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbiJSJCk (ORCPT ); Wed, 19 Oct 2022 05:02:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A828B97EF7; Wed, 19 Oct 2022 01:56:04 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C701361802; Wed, 19 Oct 2022 08:54:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D63ADC433D6; Wed, 19 Oct 2022 08:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169682; bh=XvxXrB03lskT/0SF6VJa6ZjRDrEAMuxJWTrz1oa5Eus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J9inPIEvlWkd2snhcKavQ8FFC3GyVTz2kWjmAQ15kYE0KPSRGGGH56xRwo1Y30/1z mZjwsjvfaafKz1g+6rsOlMTpHwP4xo+EFsrpUqzUCRYE5jo+rLwfHqyqX2SuPTbX3l G/RasUMEvAVcU5wZYiAj7tDlpVyFXnaR3hZhxwak= 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 6.0 341/862] eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address Date: Wed, 19 Oct 2022 10:27:08 +0200 Message-Id: <20221019083305.132887688@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 546206640492..61d1d07dc070 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; } -- 2.35.1