From patchwork Wed Oct 19 08:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp212938wrs; Wed, 19 Oct 2022 02:08:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wjQ31FpWv53Ae+a+auhKsKlTtTdIQjfSqIeS8lv2F95897F6ZrvrhqA1h8kUaSdAmO/av X-Received: by 2002:a17:907:7805:b0:780:24fd:c4e8 with SMTP id la5-20020a170907780500b0078024fdc4e8mr5857849ejc.78.1666170524704; Wed, 19 Oct 2022 02:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170524; cv=none; d=google.com; s=arc-20160816; b=oJQyIncJbMJm+r7IEo91pe+3ufVauWC2JA2xmc8bC/CMEIZPtr8aTOnJclHVPNRvhJ YhUrp6btElibZbRDh32CvoyaYgOrowaUSv6AxawFEnKEvCOyn0+eZRkXP82hzFri6/Ji fZbtuXwiHXb0oD8wuQLMdZOh5hlgj8p/SOne3Wfl3OwzxU9kFiokp7aIG5f4QZUeCRww clSp44KhmrOv8ci98eEkq7pqQmsxRGK0QTy1qmazWWJc2JSPjXjkMg5cB9XiUFpr22YY 0PBgDsmPAc6N7kXJpFVbJPCjQ7s5uzJ9rUOc590QT58IIg/J25RsCQnf8vXcXocRFs3V gSlg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji6-20020a170907980600b0077e8ff79426si14412824ejc.511.2022.10.19.02.08.20; Wed, 19 Oct 2022 02:08:44 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106424614134767?= X-GMAIL-MSGID: =?utf-8?q?1747106424614134767?= 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; }