From patchwork Wed Oct 11 08:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13416832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 590AECD98FA for ; Wed, 11 Oct 2023 08:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XbWFa+L0RNOgwqM3UoCnftNP8xBcjyxS8H+XZvTw9hI=; b=K14QXgFocPEhRk uteCnX50InbLTNe9afCmo7XNM4pyA3oq3/f0jZA0zuBIi+HF5bsAwp3G+1XDBO1JTj6kbiITmzzHl 6dEA3TaQnT/JjpQiUsdcB6y6mV1wadhbFhKz0CCX4AKrrEI2dyO7UJCdwFaaDExrX+O/PGEfsDTWl ZKij6xL848zT9ZbpOrQctlQNbEAaysJ9ts/qq20JiLIh6i3d/0DLkFjVWM8D2QXVEsTrhs1YMppr4 gY3XwDH+36obiNF6A2YpBaTq1buX9QYbL7pkIw8G3SMyf0zonZcGX61mIupbvnGncgAOooHFJdTG6 AgSBl9/0yxkOXdI5L48Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqUAI-00FBOC-2X; Wed, 11 Oct 2023 08:01:58 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqUAG-00FBMW-03 for linux-arm-kernel@lists.infradead.org; Wed, 11 Oct 2023 08:01:57 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso61127655e9.2 for ; Wed, 11 Oct 2023 01:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697011313; x=1697616113; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=YZT/8mXHXiKgkNO5lwynSIruokO6XSAvA489Hqpy4Bo=; b=TAH5fC2hmCSeMp7yXp/nfq2f90Rz6P0Anq/U5LYqWfiPdA2uQ6G1BTqWNYP261JZ5i ujNYH7lAnFsFxzH7OOHLPhtM8gFmyn36NoAtmywlxmMhtG5WH6NPyWuqWbxQ3jDG/CP4 uQ3KTwMekHwRm8cwirwOur1EBSYgfqPwRpFVb4JnvaUgXDxZIsL9bxVxXdbWEq7imD0S 1E/LV22vgcYL5qZJSNJOw8w5D4+fnPRccDmdNk8DiApQoJyqEk6UlMjN46HNomWageD6 CGSR8IelJA3WnP6A2ZGLS6o3PPg7odU7gQGPk28ZBO64FCGCAXwpYRiHV/TSQ0NKE0Ug S2LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697011313; x=1697616113; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YZT/8mXHXiKgkNO5lwynSIruokO6XSAvA489Hqpy4Bo=; b=KN3VaH2+nOxHLRHHMNU1KVIghzYzbDfbl6HUwrSZRcxpuB9ZfXWLO+PF2HptMlhzFF 0TcI2wlG+6n10MuZ7uVDfh34vMkhSwTLv6pq0jI/CtWAoHbnE3c9voBnkIuz5K6/39ZP aV+BScSWRnEKJWFe/bxy1SO2f6Zzr/8TezXlfVIhWvbCw/QoM0cqL1mwQEqxh6wGSqxF rWb+rS+BllGNUHcwAqpgD7rw6N0GGAHmrerqT6c8y5TqsQEjaZDTeFz4XH6TqN2PEwPE E6IRDY6SUYA/H1M+QSI+R+POWuWFokMaYb7oB7DpzswPxqMuiQgY8VjHTcEPyEQB3fBF wtvw== X-Gm-Message-State: AOJu0YxU4ZlxSGmMjTVRtAk5f6KgeyhKw55U1YBrpdzUpsyRlfyEoReI QmVH3/y8V9rwQCYMj5y14rtW3A== X-Google-Smtp-Source: AGHT+IHlYGaipThrXKIKMr2CcQW1kf8ZvYk9AY5BdTWtgsZ4chvat2yBykWEZU5sAaKVW2Tsl/EQeQ== X-Received: by 2002:a5d:5911:0:b0:324:e284:fab8 with SMTP id v17-20020a5d5911000000b00324e284fab8mr19093365wrd.39.1697011312630; Wed, 11 Oct 2023 01:01:52 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id n6-20020adffe06000000b003140f47224csm14690117wrr.15.2023.10.11.01.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:01:52 -0700 (PDT) Date: Wed, 11 Oct 2023 11:01:48 +0300 From: Dan Carpenter To: Tomasz Figa Cc: Sandy Huang , Heiko =?iso-8859-1?q?St=FCbner?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shunqian Zheng , rjan Eide , Mark Yao , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, kernel-janitors@vger.kernel.org Subject: [PATCH] drm/rockchip: Fix type promotion bug in rockchip_gem_iommu_map() Message-ID: <2bfa28b5-145d-4b9e-a18a-98819dd686ce@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231011_010156_052054_D7B47D11 X-CRM114-Status: GOOD ( 14.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The "ret" variable is declared as ssize_t and it can hold negative error codes but the "rk_obj->base.size" variable is type size_t. This means that when we compare them, they are both type promoted to size_t and the negative error code becomes a high unsigned value and is treated as success. Add a cast to fix this. Fixes: 38f993b7c59e ("drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain") Signed-off-by: Dan Carpenter --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index b8f8b45ebf59..93ed841f5dce 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -40,7 +40,7 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj) ret = iommu_map_sgtable(private->domain, rk_obj->dma_addr, rk_obj->sgt, prot); - if (ret < rk_obj->base.size) { + if (ret < (ssize_t)rk_obj->base.size) { DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n", ret, rk_obj->base.size); ret = -ENOMEM;