From patchwork Tue Sep 14 14:02:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12493585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53D62C433EF for ; Tue, 14 Sep 2021 14:02:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37F2160F92 for ; Tue, 14 Sep 2021 14:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233604AbhINOEJ (ORCPT ); Tue, 14 Sep 2021 10:04:09 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:55511 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233572AbhINOEG (ORCPT ); Tue, 14 Sep 2021 10:04:06 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B1E6B5C01C0; Tue, 14 Sep 2021 10:02:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 14 Sep 2021 10:02:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=9FXyPXkwkycT7 FpDBprBIlpPCJk+3RJgiVL3MbYdviE=; b=bKMd6ghzLgrKYQk8XadO3FM8GCSCw eRWRkjAM21IQ+Z2WCJVDDh0FFyNelPRfeewZnfWsCD6ea2zye+59QAlZMjt6rYk4 5R75UfmuFsYmqz776a+qVyQUXstIqIlvnNGMLCav6cyHsPsxxpaiBoTpKUxwZf8T y+9vkAc0UkkH4h0r2rm0VGbHa76U1MQJwEAN8zYUvaL8Mb7RHc/ahnW6Le/SN9gQ HyQOOcfAdmQ9Nkg35lZcQrOXO7bVm29nqthLFLs7ADhUMD0CU3L3zNr7txqo0wKW QkPhmDGiiY6wvBz56yfuPjRefRViYjAtvZWf2PTD259bwrmXnO9LBLVXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=9FXyPXkwkycT7FpDBprBIlpPCJk+3RJgiVL3MbYdviE=; b=EUe6hKO5 m6M6Ib2Pc29ULZbERVZyQpfN40C0lbci26ar3b0XUoP/OOvpPyqXwTJ7wxPn0UK3 KSS22yTHHiGhwFCZKJ40PH0Kf/uPhSI6UY3/p6HiMdY9YBLyPXVh1MfTKdwMeHdG x2kjFDmdLtdNvTuCWjC8ra5UPKAO1UpUf5+eji7eGVsmzTnztN1+LTTBrUxR452U ZkO7jHDC2gShD1Zk3lrr68aX8+q/02FyhMRsmEPTkqd8X2NHyfEYhe02l0ItFWAb nNWbH9Bo80JdtpI7z/DZVcWnwcfo1yMTMFpZ4Ki2nyZ1+TYOmL9ywHCr5aNOFvjH 2u38RUczPsNJWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegledgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 10:02:47 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sven Peter Subject: [PATCH v2 3/3] usb: typec: tipd: Remove WARN_ON in tps6598x_block_read Date: Tue, 14 Sep 2021 16:02:35 +0200 Message-Id: <20210914140235.65955-3-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210914140235.65955-1-sven@svenpeter.dev> References: <20210914140235.65955-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Calling tps6598x_block_read with a higher than allowed len can be handled by just returning an error. There's no need to crash systems with panic-on-warn enabled. Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- v1 -> v2: - added this patch to also remove the WARN_ON in tps6598x_block_read as suggested by greg k-h drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 8c79ba17a157..93e56291f0cf 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -117,7 +117,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) u8 data[TPS_MAX_LEN + 1]; int ret; - if (WARN_ON(len + 1 > sizeof(data))) + if (len + 1 > sizeof(data)) return -EINVAL; if (!tps->i2c_protocol)