From patchwork Tue Feb 13 18:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13555458 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 CF672C4829A for ; Tue, 13 Feb 2024 18:05:31 +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=iDqdE6I3umciLGNop7rIPAaG2guP0CcKmEmAL4LDxdk=; b=Ucr1k+3LZo5iqq mG0nI+bJFn0hUQqYVa0dy/vlOu/8KGGPU+8ZjJPq73GJbyrjgP+fltn8yagdqPpHtOkre4hKgiSDZ 7Li14ACYKxlVvOkkgl8A4j7uhRtk2jndHlkQOs4RETxRcy43v8m4W95k+wf9lB7ABvq8r1WMzM27m 4q7U9iBqyU7/vQ0+APRya3V4+DQsh6ZHotQmxuwnCucZI2GazhZfbPlru6T85FiKDno/NIVI+szIu bddZmedtSQHBheRlA+y6TJu7fUerBP9zKF29QYex9RoiV66NSELc6QkUHPiAzm3nMDeE7RGSe4G3j eRBectUBb71jOg/3Opmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZx9c-0000000AG5x-1PJt; Tue, 13 Feb 2024 18:05:12 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZx9Z-0000000AG52-3ef0 for linux-arm-kernel@lists.infradead.org; Tue, 13 Feb 2024 18:05:11 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2d0d7985dfdso64552901fa.2 for ; Tue, 13 Feb 2024 10:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707847507; x=1708452307; 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=e70wXDD4s58i4pPQoq+fOfAGn7fmyRVc02WAzyBJDv8=; b=PSt51kny5xm1I6dnLNwvZI7gbtv6LFatQ1JKL5B9q/NV5N9v8Y7W+hmdzNmo8AHyRZ coxCf/TFs/93UK3yxSbfNeRFh7LWlOTZzuBEJuSc4/l9cmeTCSTvkKtFhaYfiBqRwN/w x870Vt1du/tJlQAMxZ6gfs0OAHsRa+BZ8RNTkq4dis4s0ttaf/Yq9XjY9IecAVZXvU5f sXDtU6kEl2Qs4doT6W0mZldGBLW58dXWzKf9gd+eEvdZqWNBIj7zM0AXpjbZ9kySEQpZ 106fw3rZk4uPvj9IXc2IMgJdGgP8+KdcnDm4hgFJpt3cMU3bkpX+/xfUt+2+JSrx4erU p3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707847507; x=1708452307; 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=e70wXDD4s58i4pPQoq+fOfAGn7fmyRVc02WAzyBJDv8=; b=v/8ONRz9pVavJSrrXi9rABDrCoLur7Vd8XCfYoQBQK1tO3mJMlOmh8wmddehhMHmfu yPUwb70HXlq1NEU1w9rKFvtvzEj+4EdWY87arXHPQVEhmzQ8NE0tm1WCopnBr6fVptwX tkKOGti5LLw10YON3/N83xGusKVj0aZui49osbU6gloovoYhEjKLul5TGWEI41fYu6vK d4RSwWUUbfgq00O9Ttd0ZII/IJ6k84VVjFf7IJ97jheFh6xdSXq715ZF+cT97wyo6T5Y X6QgV/29qB0FEOix9LmgH87MRiZabhmIUIug3NDxa+UkL+274BRx2uHl8Tsc79nudzWT UyIA== X-Forwarded-Encrypted: i=1; AJvYcCWStSKWf3bZh3Ko5cedX/xExhjC7gLBTK4SZ1f0uJGt8B6mx7AARej8l0/WCgptjxMLS8UqVc8WKvBpDytzAk/zZ4eKLlgfecUovBLNlRgxScdZvL0= X-Gm-Message-State: AOJu0YxgGbpGQt5xfaUWSHUMbc/yhw2x25uR3oimsXpjwXRzTl7R1qix BfFgrb2RoJk+/3Z+qj0871IdgTKIZY3FDTB8Io7/ywyvjIrfwOASBfEdxbIh6fWpBB3IbrswsVd y X-Google-Smtp-Source: AGHT+IHmkNgIi7TzfvE847XBZ2OZM5yDgs1O1Gu/TDGtB1RJErk5/dezneWdy7eJGVqq6KcPWyHDug== X-Received: by 2002:a2e:2e09:0:b0:2d1:ca1:760b with SMTP id u9-20020a2e2e09000000b002d10ca1760bmr297273lju.30.1707847507407; Tue, 13 Feb 2024 10:05:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWZ54WrawIOvlpxGz8yZKRDQ4SqXq+ERsBBvUjJjAj9qIo+bWEyrtNeTqIAiLi9LXVheQhFRx9UR6ajW92PZ+CvHLgnewa2EHey+1qbM5k6vFOqj97RVJ+DGojyFT8KwZtvgHrqGU9IPR4yGbV7GBdYJt2IULruG++q1lypc0xAkiG2Oh/ePKKJ6k0cZhn9x5CzoFHWTvZDrU1iQBLyUrF4Eb7KG6vjhkTVbsR4+YZjkeZz2Lk1kUd8QLhJoDAtCk1qKUv+RisDC2l7/yiHlPLnJhOUrqkDMCPA7waGTcg8DdN1tNI0rceLgid50LvlR+6BNKq+VGapvGwAv7CEq41MUsQZ3gqHFeawGmBtfuvghXbxoeYSC1mp06StN5ZL5lVqWurMvYL/OHtrq7O7wOQIedPShPXsBh5kTf/q8wxfD4HTEIlEbjP4G70TvEm8D8Qz+gCu+8umWLo3TMvAem9GcDkf6HfHjRUFvRx7pMOG0uBBd1d6DBNRXpTN9PIikhzbFmHUOIGYLC1v2rqRSMUXHdyKfCfUV9S0qT1C0C6U32aKxY2L4cQLx8CQW7drWAr9rDxmjV8VgdM3fmQhTstf/Q== Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id j1-20020a50ed01000000b00560ecb22d49sm3827246eds.84.2024.02.13.10.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:05:06 -0800 (PST) Date: Tue, 13 Feb 2024 21:05:01 +0300 From: Dan Carpenter To: Philipp Stanner Cc: Laurentiu Palcu , Lucas Stach , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] drm/imx/dcss: fix resource size calculation Message-ID: <4914592b-4256-4c9c-bc1d-6dec1e473831@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-20240213_100509_932299_55DAAD4C X-CRM114-Status: GOOD ( 12.12 ) 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 resource is inclusive of the ->start and ->end addresses so this calculation is not correct. It should be "res->end - res->start + 1". Use the resource_size() to do the calculation. Fixes: 90393c9b5408 ("drm/imx/dcss: request memory region") Signed-off-by: Dan Carpenter Reviewed-by: Laurentiu Palcu --- From static analysis. Not tested. drivers/gpu/drm/imx/dcss/dcss-dev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss/dcss-dev.c index 597e9b7bd4bf..7fd0c4c14205 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-dev.c +++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c @@ -167,7 +167,6 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) struct resource *res; struct dcss_dev *dcss; const struct dcss_type_data *devtype; - resource_size_t res_len; devtype = of_device_get_match_data(dev); if (!devtype) { @@ -181,8 +180,7 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) return ERR_PTR(-EINVAL); } - res_len = res->end - res->start; - if (!devm_request_mem_region(dev, res->start, res_len, "dcss")) { + if (!devm_request_mem_region(dev, res->start, resource_size(res), "dcss")) { dev_err(dev, "cannot request memory region\n"); return ERR_PTR(-EBUSY); }