Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1313517rdb; Wed, 6 Dec 2023 15:18:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG09rtF6HPjmpvhAxCEu3Qd+EeNnD0TbTmrY4dv3ZKiPn1CFF7j9x4Qxla4U9aoQs1O6sCR X-Received: by 2002:a17:903:2344:b0:1d0:6ffd:adf9 with SMTP id c4-20020a170903234400b001d06ffdadf9mr1383700plh.96.1701904716844; Wed, 06 Dec 2023 15:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701904716; cv=none; d=google.com; s=arc-20160816; b=glHGIthNY0VkHiwAikJpzhjhqUS1WJBfUsqtNcDPsg4sNhy+cH1PShl4mIkOJ32Vov dGqw1drMw0ovDMzfw7RA/+79MIQzU0lSw6Wz0OIVngIyc9A6WWixsNILpezktCpxzJJv RFfl2PbaHaItdPL4++bM5UqIQf77y1aej+T/dyYL1Fxq7YfXnTEqEsxmT/kBD9aQhrBh Uyo16zD0G/JBEgCTXezm9HQd9f9thNNrgTJZ1dq7CACmZTqVJuRvPjpi+je1QBsap9qk UA7JYtxlZ/6lBTqxcFy7KoHGt+oTry+HJ3voueZfz3+QjLcg+dlFWhNYInWf0nslKBrM qI+Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4nIdsTL05i/fQcKGuxcdEvUcSTjM6r4SYAxOvza2riQ=; fh=XjWMGZLmH9qKWKwKp7YWjCeiSm2DM8dAydweZsdA3Kc=; b=ozW5RxmFlaBP60M3IR6m8CRykOyFXtPNvkljQ4V7BoKFeSreaIWGeRXEdcmG013APS KmWtdwuWNwhySTGt+Vq3+CptQFicWykmlrD7v5r1+UfpqN6SFH/p/T3bN+3H4ZtkH2sb Y84J6EHjBj4MrnPZVBZKYQkIdOkS2iCbvv0VwC66yhu5ajTAsuAUhcwYihrcYA5o2YTN aG0Ut5jgPQDUVkBjCVnZU28TJlzPC9CKAsLe1crUEP3ta54q6eXlKO28ambmTcLO8ofU b64QoflDkbRo10jUnGR1+iR4WRu5HQ74PGxDabH5Hyr+TD9ixzvCdTahCPJjYLePKOg1 lkIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="t1v/QW/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ja21-20020a170902efd500b001cff62f4c75si9978plb.53.2023.12.06.15.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 15:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="t1v/QW/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 05E7A81EE533; Wed, 6 Dec 2023 15:18:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441796AbjLFXRq (ORCPT + 99 others); Wed, 6 Dec 2023 18:17:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379631AbjLFXRc (ORCPT ); Wed, 6 Dec 2023 18:17:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8979D68 for ; Wed, 6 Dec 2023 15:17:37 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5250AC433C9; Wed, 6 Dec 2023 23:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701904657; bh=xHlmGR20SCrHf8Fi+WuUdvFz6wf3sL0KK/pWnjjJEHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t1v/QW/16H+qXUvY+0BysMSAcM1TrX8UQoPoodoywnixyHSWOX0FleDPIUyTbzsKh Fdp39iypGh5vfvEkubP/VBns0GzPnRPHZx67aEAdvYBFhmlZz3/3aRgNoH23J5JdI6 mIOPe9o9uqQihp3rNJwVvQVYCgyYzDHqyqdL73IZPu0Svyx+c9PkqQUM9YH1Gny9Ly WKTYtGbmr+Sb9SlWp5+VcnH+98sqWoa6swfZmd1yE5D4b7cXKmv2ZG629mYM7Cgi0P +Wcg66LT40iYTvGlAFr51Jk5G/BWc8GgtlMPMwAX3CWAN4Gahea5lP7S9dYMEsZkEa fATtFkcS851Iw== From: Stephen Boyd To: Greg Kroah-Hartman Cc: Sen Chu , linux-kernel@vger.kernel.org, patches@lists.linux.dev, AngeloGioacchino Del Regno Subject: [PATCH 8/8] spmi: mediatek: add device id check Date: Wed, 6 Dec 2023 15:17:31 -0800 Message-ID: <20231206231733.4031901-9-sboyd@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231206231733.4031901-1-sboyd@kernel.org> References: <20231206231733.4031901-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 15:18:30 -0800 (PST) From: Sen Chu Add device id check for spmi write API. Signed-off-by: Sen Chu Link: https://lore.kernel.org/r/20230518040729.8789-1-sen.chu@mediatek.com Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Stephen Boyd --- drivers/spmi/spmi-mtk-pmif.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spmi/spmi-mtk-pmif.c b/drivers/spmi/spmi-mtk-pmif.c index cc660da6a037..5079442f8ea1 100644 --- a/drivers/spmi/spmi-mtk-pmif.c +++ b/drivers/spmi/spmi-mtk-pmif.c @@ -384,6 +384,12 @@ static int pmif_spmi_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid, u32 data, wdata, cmd; unsigned long flags; + /* Check for argument validation. */ + if (unlikely(sid & ~0xf)) { + dev_err(&ctrl->dev, "exceed the max slv id\n"); + return -EINVAL; + } + if (len > 4) { dev_err(&ctrl->dev, "pmif supports 1..4 bytes per trans, but:%zu requested", len); -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git