From patchwork Wed Oct 19 08:32:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223994wrs; Wed, 19 Oct 2022 02:39:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+XkP8YOvKSXcVykxPpEZoNrxIlzr4YO20VMMG6ajwm2J/vZWcR+ptVvmzlco4qvtjw1/X X-Received: by 2002:a05:6a00:acc:b0:530:e79e:fc27 with SMTP id c12-20020a056a000acc00b00530e79efc27mr7796028pfl.61.1666172343660; Wed, 19 Oct 2022 02:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172343; cv=none; d=google.com; s=arc-20160816; b=Ve+UU2M+aDQ4KN0Zq3Bg9I5MyLtPcz0Wncqtmncdikxm64KVJOQrbIo20facEX86sm Wh49Pzq73BH9EopjfdsbJmhQafd6x9v9u6cof2NqmI30UrO8Ya715inpJHVXe50BN11g hOQmRNA4ZOa79fC82ke9G8LYvHH2uR7RYw/dE7i0pZ7iDAueTOfPmW/E6DQ/LXD98ihR jlihwlKVHseAjxB8sWuKRoq+k9Ec/hktQh5DMzwXBcgZLhm5kyw/nuzRUQCLCS3+LQfS /dgoptcEx6kV2eaoYpsIluBbVNMqNUTMG1IqNHLhyV7JNGrSJzLAsquOWaP8MUrD3z/B Hayw== 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=A+noVsxBQRrRt1rEKLR1y1koYzp4cSkSddtGXmTg9TI=; b=az7tj2cgw3kZgaWovoNOsEECeGI6n629sh+pXxC4ygxGuMC+3B/y0Hr/o5pYElMMrE OqsIkDHFvJwehDPyLzJ/KTqymPgtIDtoDStEUgzvv11Rx+m5/THW5xjHQRayzQs1nd8W ChaUwsTM6dJBSxAifuAlrPqX/AVzWAOKol3tLMhrCTaJiS/QY1O6KOqy3F8NeeI3EPWC IPvI1WpcFJoPjTKT0JH49CTepv8iCizPjpZ4neGpTQl+Nm3p7bFhMhU6u6xfI2zRhv9T TaOxHNE8KJgMuTmDFjf9kD+H2IyOglrIW7toTpjXuxCTroae7VjjWL9MH+n/bQjJMoFn wI5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KZvWdf5f; 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 y15-20020a056a00180f00b0052abf46260dsi20074937pfa.25.2022.10.19.02.38.51; Wed, 19 Oct 2022 02:39:03 -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=KZvWdf5f; 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 S233445AbiJSJZW (ORCPT + 99 others); Wed, 19 Oct 2022 05:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbiJSJYJ (ORCPT ); Wed, 19 Oct 2022 05:24:09 -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 E8244C512C; Wed, 19 Oct 2022 02:10:54 -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 B9DBF61881; Wed, 19 Oct 2022 09:08:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCE78C433D6; Wed, 19 Oct 2022 09:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170523; bh=Kh8Sla+Un1KkjfHIh8LWbAk/NpfHmZyyc25lnnifXUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KZvWdf5fteZLWm92HtK/gkC+EEh8tHLxc5ZWTc3oFGo+UfJU1Wr6taiZJAAfMVpfu qxFz8Pc9m9cEp+5G/Q0OHtCEIHHNaPlmyZJsADwXJ9a/q52aJwQwOHzLSUviPVy9/7 NXtreP4JNzTU+11Xe/UaxXss0r+hjOEBiQBefwzk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jerry Ray , "David S. Miller" , Sasha Levin Subject: [PATCH 6.0 688/862] micrel: ksz8851: fixes struct pointer issue Date: Wed, 19 Oct 2022 10:32:55 +0200 Message-Id: <20221019083320.383736530@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?1747108331319671440?= X-GMAIL-MSGID: =?utf-8?q?1747108331319671440?= From: Jerry Ray [ Upstream commit fef5de753ff01887cfa50990532c3890fccb9338 ] Issue found during code review. This bug has no impact as long as the ks8851_net structure is the first element of the ks8851_net_spi structure. As long as the offset to the ks8851_net struct is zero, the container_of() macro is subtracting 0 and therefore no damage done. But if the ks8851_net_spi struct is ever modified such that the ks8851_net struct within it is no longer the first element of the struct, then the bug would manifest itself and cause problems. struct ks8851_net is contained within ks8851_net_spi. ks is contained within kss. kss is the priv_data of the netdev structure. Signed-off-by: Jerry Ray Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/micrel/ks8851_spi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/micrel/ks8851_spi.c b/drivers/net/ethernet/micrel/ks8851_spi.c index 82d55fc27edc..70bc7253454f 100644 --- a/drivers/net/ethernet/micrel/ks8851_spi.c +++ b/drivers/net/ethernet/micrel/ks8851_spi.c @@ -413,7 +413,8 @@ static int ks8851_probe_spi(struct spi_device *spi) spi->bits_per_word = 8; - ks = netdev_priv(netdev); + kss = netdev_priv(netdev); + ks = &kss->ks8851; ks->lock = ks8851_lock_spi; ks->unlock = ks8851_unlock_spi; @@ -433,8 +434,6 @@ static int ks8851_probe_spi(struct spi_device *spi) IRQ_RXPSI) /* RX process stop */ ks->rc_ier = STD_IRQ; - kss = to_ks8851_spi(ks); - kss->spidev = spi; mutex_init(&kss->lock); INIT_WORK(&kss->tx_work, ks8851_tx_work);