Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3084596pxb; Mon, 18 Apr 2022 15:30:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8XUa27UgsCCkCQwXGAWhhjM+m8xcm3+qs7ZSaQUvf8G5mgRn/pqjvTQex9jF3qTgPvfjt X-Received: by 2002:a17:906:c1d6:b0:6d6:e0a3:bbc7 with SMTP id bw22-20020a170906c1d600b006d6e0a3bbc7mr10899360ejb.484.1650321026411; Mon, 18 Apr 2022 15:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650321026; cv=none; d=google.com; s=arc-20160816; b=yQwNU81uvadOb35qIHhvLaLXwpw79ArN2x7hgNDbDhz/n0N9y8W7S23eVTuzlesBGN atkQuU1tAWrSDPkv/5ynAgC4cdk+i9ktqCpbgjNOz+qs+nwjdgJuek4M+oyUy1mIq9RY coR2jhYb5aeDaYqnR198+dF4/0CGpPgmQnC3mDhdlfIhOwbV44FyFFF2zD7/hZ2u1asL 8zgeTalxoH2/9KuORvbPCKGWbDS6VZIroZ9KCjkHEfPqG/kJs+EkFNuVGFX29oRJZ2C5 intihKtg6CKwF5RLCx3kgkW4KQvS1TnwznWbpaerOmL3ygNHaCnz6zsnmY+kNn9K8mZo HCnw== 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=dBCAFwrLLv6gCfLf/gQzMSm2D/raJYyM/NHZpzEh94g=; b=aRSr4g+yKJTJ4rUXHbrkbh8iLkI8z4M63XTYQGlcM2SQC0A+YJeAk5GY2Y0ERN/CFy lcN2h0Yc0cNvPfJIKGJVhEmWw1JpDFa0eNEaBbFD0EbsPJnymz6HAfIcKFIO9xUkFEsI OcQxTt97MwYfhM0X/wUjH9OIGSwgfB8CJuEbOyCu/DIk8SSAz9uYpOdVsWiu0Te5TOqB g00mDXDEvHqEKYO9aKr4bIEEyEe5XHQCIvXLC8k3oyuMWLFx9xA0lHLPn3icxljM+CPX pvBbpGaQ9QUQdMrHkupOA3AISi/UcoEX3CLaW+JbNcW+6B1QXzd4wFd1TOWPDb5wv/8U OYbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nMLT+r96; 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 z18-20020a05640240d200b00423e88cfbe1si2841256edb.588.2022.04.18.15.30.03; Mon, 18 Apr 2022 15:30:26 -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=nMLT+r96; 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 S243165AbiDRNkr (ORCPT + 99 others); Mon, 18 Apr 2022 09:40:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242957AbiDRNJn (ORCPT ); Mon, 18 Apr 2022 09:09:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3E5336E0A; Mon, 18 Apr 2022 05:49:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id 000BEB80EDC; Mon, 18 Apr 2022 12:48:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48446C385A7; Mon, 18 Apr 2022 12:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286137; bh=Y5zWl7U5Otlds0oDof3do24rzGWPA9Fl6NP3DV3Vw0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nMLT+r96lgd9AJru7MM44iI1IboT0IkPEQH1xb6Q913pQSoLhbANB1AKh9GdJpcj1 N/wkFwzP05QCyjZzP0UBUmDzRfsZaU9QmW+52uh4lM85KrEaSsflnF4XJg73Bfr2VZ 4QZvHWQbitZk45/3EIZiNwgC/GIZdrh/GN8e7DkI= 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 4.14 006/284] spi: Fix invalid sgs value Date: Mon, 18 Apr 2022 14:09:47 +0200 Message-Id: <20220418121210.877635778@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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.7 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 71f74015efb9..d26aefed16ac 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -774,10 +774,10 @@ static 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