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 9B328EB64DD for ; Sat, 5 Aug 2023 10:10:52 +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=uYRugkwSWKM1/G84RHZvKgaSOa1dFXVKwoSn4Cecpqw=; b=iUMm6FQD1kbef0 w4/+wTEkQViK9egx1hexYZK5wdOX46CkEyYd43FAdzByd8m0xQYNVL4LPacxUj8IWPrgqtcRppVvt b07iIjK1pDZ5XuB7mdTAf8WIAmBiA3+m4q4Q9M8tA8I1dOCBzJ3c4cOfQ5CimMNd1BOokGnyLagzB JSkO5ylJHJcbAAr1f1BjpjFMDSw70fYi7GQad9UDUlxHSJbDze3L7RH3/vw9TFXhtra6hGwTWiFYR 2yNsBcGE9Tbd7bL6K0q2r1DcpmuQm2DNyYl0Ke7gXaQSCP/+VJPAO2J/Q8p9fctU3tcQJW3bYe2Kf pWGvedWLKZVqLd9nt6WA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qSEEs-00DvHj-2L; Sat, 05 Aug 2023 10:10:26 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qSEEo-00DvGM-08 for linux-arm-kernel@lists.infradead.org; Sat, 05 Aug 2023 10:10:24 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 277E860C41; Sat, 5 Aug 2023 10:10:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37E34C433C8; Sat, 5 Aug 2023 10:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691230206; bh=RZD/okUT8P7W5bz60THY3oriTvZX3Irx0g2o/7jpNgM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nXu7JJHLU9Jooam3uyoQ6e0wCkbz7xIrGiNIEzv+H/djdFeKyXyWdoZ+cS3ex/nwx Hf9os47q9i4O8rPUaHQEgCCnGE2sIREgy0TXaQFDlx0XI6OsZZ3twxM2UKb2vu8lk9 VjGfrOnun6jBInNaow/vZ6xwduNClFon1dJhbxDxobyoV0jJhVMfWkTshDyLIiZXx8 2JpDieuy6NeBfihyEuejwO1jTP//MyoaxMPoQ32cQNoIQeXAk9HZXylYzNVrd8TKZc kH3hOayvpvoIsew6gxod6r315LuWEQMQ0jQq40j4QCIftMqMIxr0mjwDZBTOR7cW9P a8t3p6xKC7M+g== Date: Sat, 5 Aug 2023 12:10:04 +0200 From: Andi Shyti To: Lixue Liang Cc: brendan.higgins@linux.dev, benh@kernel.crashing.org, joel@jms.id.au, Lixue Liang , linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, p.zabel@pengutronix.de, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] i2c: aspeed: Avoid accessing freed buffers during i2c transfers. Message-ID: <20230805101004.dknxj7nqrt2aes5n@intel.intel> References: <20230728122416.17782-1-lianglixuehao@126.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230728122416.17782-1-lianglixuehao@126.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230805_031022_140684_358E3B6C X-CRM114-Status: GOOD ( 16.54 ) 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 Hi Lixue, On Fri, Jul 28, 2023 at 12:24:16PM +0000, Lixue Liang wrote: > From: Lixue Liang > > After waiting for the transmission timeout, the I2C controller will > continue to transmit data when the bus is idle. Clearing bus->msg will > avoid kernel panic when accessing the freed msg->buf in > aspeed_i2c_master_irq. actually in aspeed_i2c_master_irq() you are already checking for !bus->msgs. What kind of panic are you referring to? Andi > Signed-off-by: Lixue Liang > --- > drivers/i2c/busses/i2c-aspeed.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 2e5acfeb76c8..c83057497e26 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -713,6 +713,8 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, > spin_lock_irqsave(&bus->lock, flags); > if (bus->master_state == ASPEED_I2C_MASTER_PENDING) > bus->master_state = ASPEED_I2C_MASTER_INACTIVE; > + > + bus->msgs = NULL; > spin_unlock_irqrestore(&bus->lock, flags); > > return -ETIMEDOUT; > -- > 2.27.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel