Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp670249pxb; Tue, 5 Apr 2022 18:06:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVQMR5Md25Qy3/3jTPdvj7N9at5PpweMv6pnRh2brXMxKQTlxiNSpot3iAP+XqwL+HFsPz X-Received: by 2002:a05:6402:2553:b0:41c:debb:e4ac with SMTP id l19-20020a056402255300b0041cdebbe4acmr6221777edb.352.1649207181145; Tue, 05 Apr 2022 18:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207181; cv=none; d=google.com; s=arc-20160816; b=pnwzb3O3wpdSrtE0GHjf2p/GpMmu7OnJT/6/CnOLgCFu1AgOASezFqgOM45XjLTktN WBRrZmdDYSaSanyJ1qALC+LIeIh5l9XYbj3YgZtw78wu2h0bh5H/o7dP6x1Qh/2achLI UjMNCDZWxtSvGBbJjMPH3lYquJHgIpt42qVN5K27OXx6yPSQapdYKT9yBUqxDK3rB5nW zzitqQR3yPOuyr//c1vBYg8Nhll+kec+000yPNhMPA60BhL/OnkKO1yQ43w2/TQds1iK xhdrDmkDg1tYpVGQyTbWmO/xA+FJMmjSLXpSKqZiQEoYzL5VyUFO+B6oiVKJ16x8lud7 HQrQ== 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=UUdFsovpNe3k6cOmmvF3U4j27JiNyHoz+jQEVzmy12U=; b=F7Xr+AmRJWbbdEFjXFjp7d3iOIkX9HpVW2frl35mwn/X779Q+RCzrlkMb/N3gvnkiX PvEruH8AkBGcR1yVydo/+B5WUkks8w5ZNtQQOyyB6pN4oMTRASDZRt5pv6bTAU0xKvdC st3u0FKAxLIccYA5fHm8cvM7fDsHJNfX2HRxQPW1V6VaiZwaLm7Yj52vwBhYKzo8OnJE G8aSw6EIZV0KfSdY5tmJCjBtR/o49EkMrGo/RTAvffq43w3nb1s6wM7CsJV3Tz51zVnJ nAAOVyPAgP3hWRHLQyuRmee/HenudhQixV05oONnF1xOQF7MDPr5d7mUhSf/oBc/QT/m sV3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VT6whdEk; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c23-20020a170906341700b006df76385dacsi4265951ejb.588.2022.04.05.18.05.56; Tue, 05 Apr 2022 18:06:21 -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=VT6whdEk; 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 S241285AbiDEK3H (ORCPT + 99 others); Tue, 5 Apr 2022 06:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241380AbiDEIdZ (ORCPT ); Tue, 5 Apr 2022 04:33:25 -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 269ECC4; Tue, 5 Apr 2022 01:31:28 -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 B837560FF5; Tue, 5 Apr 2022 08:31:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA3BDC385A1; Tue, 5 Apr 2022 08:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147487; bh=FBkfXu/mhT7R0LqpeBgwPFRPtk0fUrWmWdEBr6i+gBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VT6whdEkv7gPNSgmjQYPbBrdmyTDr+dPDXvSGoC/Z8T+yw25ItiwK0IleaonnwgSU Ej1vTwHVHPABF36KBSjQI6d/dD5AKlfzB0mdHvXL3B3gIAJMBPbtWM3oLjFsFXE1jM hidSLkQ3lcVEKHcxFJvjEnFMVXRTk+T7sAArrtvk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Biju Das , Lad Prabhakar , Geert Uytterhoeven , Mark Brown , Sasha Levin Subject: [PATCH 5.16 0016/1017] spi: Fix invalid sgs value Date: Tue, 5 Apr 2022 09:15:29 +0200 Message-Id: <20220405070354.655777068@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Biju Das [ Upstream commit 1a4e53d2fc4f68aa654ad96d13ad042e1a8e8a7d ] max_seg_size is unsigned int and it can have a value up to 2^32 (for eg:-RZ_DMAC driver sets dma_set_max_seg_size as U32_MAX) When this value is used in min_t() as an integer type, it becomes -1 and the value of sgs becomes 0. Fix this issue by replacing the 'int' data type with 'unsigned int' in min_t(). Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20220307184843.9994-1-biju.das.jz@bp.renesas.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8ba87b7f8f1a..ed4e6983eda0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1021,10 +1021,10 @@ int spi_map_buf(struct spi_controller *ctlr, struct device *dev, int i, ret; if (vmalloced_buf || kmap_buf) { - desc_len = min_t(int, max_seg_size, PAGE_SIZE); + desc_len = min_t(unsigned int, max_seg_size, PAGE_SIZE); sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len); } else if (virt_addr_valid(buf)) { - desc_len = min_t(int, max_seg_size, ctlr->max_dma_len); + desc_len = min_t(unsigned int, max_seg_size, ctlr->max_dma_len); sgs = DIV_ROUND_UP(len, desc_len); } else { return -EINVAL; -- 2.34.1