From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 606FE8462; Tue, 26 Aug 2025 12:49:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756212583; cv=none; b=rOUeX+tAfE4UGkgNAQ6t5Uj3sCsBr6oKttXelMi+uy0fhYXM1uJL3pd+/d6aX+cuxkpcnVfAAq1eU+bFuV0SggZqpKmclWA9LyRIKN/MZu1IEEnj+DOwVdTi8Yu18c9Xe62+GdLgEROIJPmZg+XJmQz2SYKQl7I/knPMeAXx9xY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756212583; c=relaxed/simple; bh=OwZAeJxyD5Vo8i6Bln8bhI7PwldRmbVFiYNkcIAubP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nqdRMADgjcaHLdMGSCnWhPcBsIMj+yss+qzNCyIlxvfK0j5LdR87Etd8Do49IAdetZiApQo2Cd8h7m1CP5U3CSxNE4FKQq9Z+Y4GH9B43kaakhpBh7xWgSvRVAompTT1EXM1I7J31TheXrHJcZJp+e6NijsfIiT3UPCMKiv2/oQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DSWYpYq1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DSWYpYq1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E18DDC4CEF1; Tue, 26 Aug 2025 12:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756212583; bh=OwZAeJxyD5Vo8i6Bln8bhI7PwldRmbVFiYNkcIAubP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DSWYpYq11lLC5h+NeDdY4zsHSmjAv4ApKUBxKHvFjid3CcGpWa6ep2rm4ln6OzV9Z bFR0LvbGA2FPh2Jqc+T6DAC3cV4Z8UeP3pFB/jKOFSKWyFp1wOAj0b1a26Bo+NOheB LL+Y047/nEslrR21jX9reaAdIABLqhqrYkAuotTc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Harald Mommer , Viresh Kumar , Bartosz Golaszewski Subject: [PATCH 6.6 008/587] gpio: virtio: Fix config space reading. Date: Tue, 26 Aug 2025 13:02:37 +0200 Message-ID: <20250826110953.163232329@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110952.942403671@linuxfoundation.org> References: <20250826110952.942403671@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Harald Mommer commit 4740e1e2f320061c2f0dbadc0dd3dfb58df986d5 upstream. Quote from the virtio specification chapter 4.2.2.2: "For the device-specific configuration space, the driver MUST use 8 bit wide accesses for 8 bit wide fields, 16 bit wide and aligned accesses for 16 bit wide fields and 32 bit wide and aligned accesses for 32 and 64 bit wide fields." Signed-off-by: Harald Mommer Cc: stable@vger.kernel.org Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver") Acked-by: Viresh Kumar Link: https://lore.kernel.org/r/20250724143718.5442-2-harald.mommer@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-virtio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/gpio/gpio-virtio.c +++ b/drivers/gpio/gpio-virtio.c @@ -539,7 +539,6 @@ static const char **virtio_gpio_get_name static int virtio_gpio_probe(struct virtio_device *vdev) { - struct virtio_gpio_config config; struct device *dev = &vdev->dev; struct virtio_gpio *vgpio; u32 gpio_names_size; @@ -551,9 +550,11 @@ static int virtio_gpio_probe(struct virt return -ENOMEM; /* Read configuration */ - virtio_cread_bytes(vdev, 0, &config, sizeof(config)); - gpio_names_size = le32_to_cpu(config.gpio_names_size); - ngpio = le16_to_cpu(config.ngpio); + gpio_names_size = + virtio_cread32(vdev, offsetof(struct virtio_gpio_config, + gpio_names_size)); + ngpio = virtio_cread16(vdev, offsetof(struct virtio_gpio_config, + ngpio)); if (!ngpio) { dev_err(dev, "Number of GPIOs can't be zero\n"); return -EINVAL;