From patchwork Wed Oct 12 18:53:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13005368 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 D4AD5C4332F for ; Wed, 12 Oct 2022 18:54:37 +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:Date:Subject:Cc :To:From: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=u4qbIxVITBRi6uQoc5z/BbI0Mt6qx4zlvvj8shH/w/Q=; b=Wk+ymH4RGa7zTs iDvTNMtGf7JxBRfm8c3xTEAG+yAGUowROFTiE2xejv9XHcG5QwyR/Kccty7lAMPmygs6H15xhJ0aE stQk4C9c0LXKxc/y/6zA4L2G8eID5bMmzWDBh+9+q4ZTP7hTpz0MX/SHIpiHHdmRT0zR5fq0kbwAL /caBydj1ssyj4R4YezMOaHR9aps7EGRXNwBun7BC98hoO/o4sh6BmvuQBb1EIbTwXt4qOQsyyZIKu pzX8uK+hNKYhGDSdNNVKKA4pluPp/KvOD2mNkNOr4OPpfGA1KkCZsVbfEg9FmdTCGA1r5J6B69T37 8yfWgTHPcuXM5tw4SwCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oigrE-00932u-05; Wed, 12 Oct 2022 18:53:32 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oigr8-00930E-Nk for linux-arm-kernel@lists.infradead.org; Wed, 12 Oct 2022 18:53:29 +0000 Received: by mail-pj1-x102e.google.com with SMTP id fw14so16051223pjb.3 for ; Wed, 12 Oct 2022 11:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HUI2zzepOnCEU2KAh1PakPcQFkZcRivQX+cynj5FE/k=; b=G47NFXoBtILJJHsl1h9GdNIzukt6VCgb5/pFLeR7U3O5C4N4qiIoQW1NZPvUsa8st/ oPEm2Nx/P2qbHAMkKQd6lCihhUbjxai2CtXpicsaa4D5ZMIjuOiplNYvO747uR/eVsS3 qIYRG3YYLOh0QhkdC4Pj6EJGdWLkY13ZTg5uU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=HUI2zzepOnCEU2KAh1PakPcQFkZcRivQX+cynj5FE/k=; b=1whmjq2P+m+3EsnGKwbdc0Y4MSPE8iMq+Jpi1SqLyoOljHtan9cSTMXtBp7H0ANQ5b jJptCwVqxEdSE2Mcmatfqe1+Jo/Au79j+Y92SHORvo4vM7s838ypcCu3b2yfXR1UnRX2 zg53as9u6j6lHN5g2ZSsDCsN5TMsUZX4O+8Hr2Wcf1xWoHuPdx/g3Ekjdic1q/PMIOlA 1SKFzKzmpFw9xx/uDGD7IFIe2sv0tqK2TvUYuyM42G01tGhbyP78QCHOkq1vQhFsLQdP fS2eUIM4BySN+agIflE4D9sC7h/QuXIc4umGkL4f25vInKbUWMDqWmCSUZ1iZas3lV+j W3TA== X-Gm-Message-State: ACrzQf2mFsBSiDwEpd4zuHuTLR6OtcHU0KYReijF+880OEnZpBuO03vL 0qOJ49g9Ja/SeAceeBwgy/rDjw== X-Google-Smtp-Source: AMsMyM6tV4/PVbF4fBXiv77LdOk7IfPzalAhIVuB7YI1s3Hec2Euf7PJLzGzNvVQPMDGgGwcWHVGdQ== X-Received: by 2002:a17:90a:50:b0:20a:b146:e75e with SMTP id 16-20020a17090a005000b0020ab146e75emr6663558pjb.216.1665600803058; Wed, 12 Oct 2022 11:53:23 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k15-20020aa7972f000000b00561578478f9sm194609pfg.134.2022.10.12.11.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 11:53:22 -0700 (PDT) From: Kees Cook To: Neil Armstrong Cc: Kees Cook , kernel test robot , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] firmware: meson_sm: Fix memcpy vs iomem type warnings Date: Wed, 12 Oct 2022 11:53:16 -0700 Message-Id: <20221012185234.never.936-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3429; h=from:subject:message-id; bh=4n3aQuAgsH9cCFaGFV2YF2qCSZt1D1FxI4ZpoSOMr4Y=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjRw0bGTY4oQVYR+ruKC+orN1r6Teh+Od53Fv9waOT HIZn6LuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY0cNGwAKCRCJcvTf3G3AJu5FD/ wMubbkTAppw3VbhksSb2rvGtd2RwYLblLaevZVfdiIIxQKesFXrZQi/wS2Cwb6XxaSTXOEgSOffPOa zhEq33SvE4ENM7J5ZqIAPv9VqvtcX+fPBliGpBoGcWAnKCxR667DtFC9LZXMeLhmxjbPMgRAMZoOAU 4//ZxbyuL9UHpu800Xr/8nnEuJ3cMu4nHovmggaKixXK1N5GX1ZdcBWCo5RGdwh5n0Iif3o9HJJjmU s3UwoFQvJHoUqMH+FEZHmdFiJE/XGDbJ5JwNXNfpqU5x4d8xrvyJ3JbsiXmQeugU2GOZoc22W6FrwS NIN2b0hZ4FEl77gdRrWT/Vz2bTj6VuezL7QRwgolwQRuaVG6mAinZCwTnbWDttcvkNvuMy9R5MekK3 aVn0JOcp+BCMyv5VZ12X0equ31lB2Xs9L+eK9VgpfeHoIHN+RjohE6es2z0WiIfiYDtk/CG2t6vwGQ sd9WC3iTu9CgiV3pzaUDGybpycEYkapB5rMindsjvRaLBpSPcIGd89A6P06RRh5/vd72Wpe1tskKRU kYyAUVF5RAeskLkQHaDW3hXYoiW1iMipK+yGMKGoRyl7udlBJOde7Zhj8TDuPKp2KV6kuJmFZl6t/J fwr4H8dbXiTgXoSmQtZNB0kMV9isVsilNsltNeyV26+C8DN9xIJbWZO+Y/+g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221012_115326_910718_2CB88F05 X-CRM114-Status: GOOD ( 13.36 ) 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 Use memcpy_{toio,fromio}() instead of memcpy(). Silences warnings from Sparse: drivers/firmware/meson/meson_sm.c:170:17: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:170:17: expected void const * drivers/firmware/meson/meson_sm.c:170:17: got void [noderef] __iomem *sm_shmem_out_base drivers/firmware/meson/meson_sm.c:170:17: warning: incorrect type in argument 2 (different address spaces) drivers/firmware/meson/meson_sm.c:170:17: expected void const * drivers/firmware/meson/meson_sm.c:170:17: got void [noderef] __iomem *sm_shmem_out_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void const * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base drivers/firmware/meson/meson_sm.c:206:9: warning: incorrect type in argument 1 (different address spaces) drivers/firmware/meson/meson_sm.c:206:9: expected void * drivers/firmware/meson/meson_sm.c:206:9: got void [noderef] __iomem *sm_shmem_in_base While here, fix this warning as well: drivers/firmware/meson/meson_sm.c:85:24: warning: Using plain integer as NULL pointer Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202210122023.zF56nCzM-lkp@intel.com Cc: Neil Armstrong Cc: Kevin Hilman Cc: Jerome Brunet Cc: Martin Blumenstingl Cc: linux-arm-kernel@lists.infradead.org Cc: linux-amlogic@lists.infradead.org Signed-off-by: Kees Cook Acked-by: Neil Armstrong --- drivers/firmware/meson/meson_sm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 77aa5c6398aa..4efde225a580 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -82,7 +82,7 @@ static void __iomem *meson_sm_map_shmem(u32 cmd_shmem, unsigned int size) sm_phy_base = __meson_sm_call(cmd_shmem, 0, 0, 0, 0, 0); if (!sm_phy_base) - return 0; + return NULL; return ioremap_cache(sm_phy_base, size); } @@ -167,7 +167,7 @@ int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer, size = bsize; if (buffer) - memcpy(buffer, fw->sm_shmem_out_base, size); + memcpy_fromio(buffer, fw->sm_shmem_out_base, size); return ret; } @@ -203,7 +203,7 @@ int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer, if (!fw->chip->cmd_shmem_in_base) return -EINVAL; - memcpy(fw->sm_shmem_in_base, buffer, size); + memcpy_toio(fw->sm_shmem_in_base, buffer, size); if (meson_sm_call(fw, cmd_index, &written, arg0, arg1, arg2, arg3, arg4) < 0) return -EINVAL;