Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6563175rwp; Tue, 18 Jul 2023 02:18:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlE3YDvMfxAN7Z/96aYlk2h+ZXSmSNIxansrixUV0wRHhqJO8OtNM0zUkIIsQ6Ot4VgdwoYO X-Received: by 2002:a05:6a00:997:b0:66c:a45:f00b with SMTP id u23-20020a056a00099700b0066c0a45f00bmr20287719pfg.23.1689671886154; Tue, 18 Jul 2023 02:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689671886; cv=none; d=google.com; s=arc-20160816; b=STlSKVj83RUddAIHYTdXi7MWN9IPloEZy9GuDVPQvv76d2I9/zvow8WFOgsZ3dVoD0 PdhXXuFWiYEBipyKhyOlU4YcNH6P7nbTFpbuSHcY+oUBOu5pnSyhy7iCx+Sv7VN3wJaS Z+TMGFRX6y893agVzGlafCzaTGQY4nU5xeyBEtWn3db+z8UeNCQfAg/N2++52+toZJkN XfGCBNdUw3Vv+7ST3qrCYaZoZBYfZNSIDJEhrUTqgYyxGsB+Kh5Qgf0x6k/A1cMQzhpK EyFzJS7V1+Rn1RQ5wut0HdClxNeFhK3cioPo4sp1LF0E+HIr2XdrIVbvgESFXrQu4OD4 zA+g== 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 :message-id:date:subject:cc:to:from; bh=jL6T6zUPXE3CCWce7xEIKEuuvu+FT0vtNSNDLrKiyG4=; fh=l6+w3XI+7JHKTsEinDSKjgvURpASB6SPHFbJtGo+YnI=; b=Y2gmVG/m22WHgqJnu6EiaOzBiGf6IQoVK0P81x9BytspYY1LPD8Y7AXy8gDzoeTC7H KlG0AQU8VTbmk0DuYi6mt9Sh9kIbiCIMU/4koZqt33ZR8rqj80qijCfEp5+2MYLHJahT lbHl4kmuU1H/67FQJJ+gs2EFNDn6fnbkytpGva7XvGDOAqIDHnvuQeRbxfX3DGBDFNYJ pAWcIXz20N/OMsIehP6TXKCPtwLifemLlBQrsPED44YkFB3ttGlgOv2G8z9I3CxYN2IF exPO937XeTxnfHS2IcRFIGy/M8j7az9yqkiWDu27dUoZInTYMyxCemADhjG0YzimLGUM vQpA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a056a000c8900b0067e18c6d2d2si1330700pfv.14.2023.07.18.02.17.53; Tue, 18 Jul 2023 02:18:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232094AbjGRI4C (ORCPT + 99 others); Tue, 18 Jul 2023 04:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbjGRIzv (ORCPT ); Tue, 18 Jul 2023 04:55:51 -0400 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 162801984 for ; Tue, 18 Jul 2023 01:55:34 -0700 (PDT) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6686c74183cso5474505b3a.1 for ; Tue, 18 Jul 2023 01:55:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689670533; x=1692262533; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jL6T6zUPXE3CCWce7xEIKEuuvu+FT0vtNSNDLrKiyG4=; b=ABgP15rhu7WVkPoLd0KVZ0Q7Esk0dULJYgtgxAnXzXm0pfpsplqOEVeXissa0SObTp vvCyDzbABKWkTQnrw+o6peYhdfc3E7NEPQi2vkvfWLPVFbRoHVrX7kEGVdKsnT8zk6bS 7BnRW1ERW6hQxm6ME2u15qbvLYUdfPEGvpMYpBGal/s8ERucoj0fby4Mw4bqoRzY91lu ms1ISTqzB+ojYwFpkBN9RX580VnlcrivzSoBqHahNCssw1ktXiUQHTkBTiYbWb8Ag5sQ ROxR+UdcjNhKcKeTdB6w/riBbydVCj0mz/GmVJbnoFQGPdZxNk9VZUEDy70mLLLO51P8 XFJA== X-Gm-Message-State: ABy/qLYB9Rebhjh6952XKGjNmhneodwel5SpqcercrsQHROowTSClDiH k7k2awNxWzphkuP3OnVhtR8= X-Received: by 2002:a05:6a20:d9:b0:134:4f86:7990 with SMTP id 25-20020a056a2000d900b001344f867990mr7635622pzh.3.1689670533336; Tue, 18 Jul 2023 01:55:33 -0700 (PDT) Received: from dev-linux.lan (cpe-70-95-21-110.san.res.rr.com. [70.95.21.110]) by smtp.gmail.com with ESMTPSA id s1-20020a62e701000000b00678159eacecsm1073860pfh.121.2023.07.18.01.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 01:55:33 -0700 (PDT) From: Sukrut Bellary To: Sudeep Holla , Cristian Marussi Cc: Sukrut Bellary , Dan Carpenter , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] firmware: arm_scmi: Fix signed error return values handling Date: Tue, 18 Jul 2023 01:55:29 -0700 Message-Id: <20230718085529.258899-1-sukrut.bellary@linux.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Handle signed error return values returned by simple_write_to_buffer(). In case of an error, return the error code. Fixes: 3c3d818a9317 ("firmware: arm_scmi: Add core raw transmission support") Reported-by: Dan Carpenter Signed-off-by: Sukrut Bellary --- This is based on static analysis. Compilation tested. --- drivers/firmware/arm_scmi/raw_mode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c index 6971dcf72fb9..0493aa3c12bf 100644 --- a/drivers/firmware/arm_scmi/raw_mode.c +++ b/drivers/firmware/arm_scmi/raw_mode.c @@ -818,10 +818,13 @@ static ssize_t scmi_dbg_raw_mode_common_write(struct file *filp, * before sending it with a single RAW xfer. */ if (rd->tx_size < rd->tx_req_size) { - size_t cnt; + ssize_t cnt; cnt = simple_write_to_buffer(rd->tx.buf, rd->tx.len, ppos, buf, count); + if (cnt < 0) + return cnt; + rd->tx_size += cnt; if (cnt < count) return cnt; -- 2.34.1