From patchwork Thu Jan 4 05:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 184909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5421372dyb; Wed, 3 Jan 2024 21:06:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnEesl2GD69/whfq5ISPjcBigpwoH05xsRjyYIR+sPOIE+tw6BYTdJJAW4gzmHOkCCSsET X-Received: by 2002:a05:6214:29ea:b0:67f:a534:9adf with SMTP id jv10-20020a05621429ea00b0067fa5349adfmr155204qvb.18.1704344812207; Wed, 03 Jan 2024 21:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704344812; cv=none; d=google.com; s=arc-20160816; b=KkDcs4eekWaK9cOq8x0TDJxa0HdFfwKqnVwX8E6a3lN1AjjaQ72pFgebhHdKn1Mg2z o39+RGNOdCM+ekf4BlIPuxHQZCu2x8quxJsrhssD+GzCaPMOACrXsjjbBtxVAuPv/hOP QIZ3qj4GaLnYPQ8FUIOoZeFQNv9Itkh+WTUBa+t/+xxgx01IvbASb3BVhsFh9QNvqCF7 x2p8k7JV4WUeU02Ja247gtENHUexTnrykfJLIieYWz9ie98V2DOa4/G3hX7U4DbyzkbO skJgq+CWC+zLs815jSfA5fWYICZn86mW2WbnlLIi8TPkXnch0Qm9yNHNSinpLWXBAqv3 XG5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; fh=NjlAqUwycaxGttFqg4iPzaT1jGKpZGWXsOHM+munHTU=; b=VPJfpDfEVcdAlA7CZd2L1wTH9haHwfoHMI1Bd7g5lZTy5ySSLgrHadNrucEjVqAb8Y nIDSHP9/kprAGdW95LLSbkfawez/5N1Qasr0431G8aYvfmvlCzL3MxivSwVN+R8Ekp/E LNTzNGkdtDGw3wXvyLe0OnU8fCGq45tAi3s+gyk6luK8q7Rr2oLjhqSzqTdm/4Bzfqtk 2MlLe6agTG30Vpn8Vw5PK4Ur9b+xRuRy1nv4H/yoON/phjZqhyJusRHYKFKcsJJTNZlp KLWhLadQV8bikjQbk+/MPM7BY5CJmqxnFUrnFAsejBE3Efa5Q8mf8UkjEl4i1an8JcP9 OibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fM6Iz2rW; spf=pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a4-20020a0ca984000000b006807fa7c107si13871784qvb.214.2024.01.03.21.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 21:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fM6Iz2rW; spf=pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 057A21C24BA5 for ; Thu, 4 Jan 2024 05:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B39DF1BDD6; Thu, 4 Jan 2024 05:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="fM6Iz2rW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B395715485 for ; Thu, 4 Jan 2024 05:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d420aaa2abso708675ad.3 for ; Wed, 03 Jan 2024 21:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704344780; x=1704949580; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; b=fM6Iz2rWnlkCnJ2AAGjTgFN77xMNaEFKhTPkisoahrqnVBg6205GZP2A2i8Nv8B27b 8RL3MPCDZGBwHzXdpGABKQp+EdZa59l9/b8y/YnElU+xRc9MLjCnuz0iMx+gxYog9zGP gvwKPvyOdxW4OjdBta2bknVLIv+MtQVVu7iVY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704344780; x=1704949580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; b=sbV/N7odmNreN1/uu8cP7OrJA25boo9YwMrsIb8ZS2RNsiLhzvJic2tcUvyv+MyMJ4 bQM9jeEUziw2hT9foDZwJ0MX3F2941HxjIJPt+IOWeXaTxgy0ITO25BfMoOKYcJy+3a4 nQoRpKmnrNpgwVd2ptP2LSyuUd0C4WlY4WeJ7sy5JmnjgEUSh8oGmRq1B7Yl83P75F9M yj4/fGo0oKo1D4c87v99t6tKoJFP2cncrMlJuSIQqFJas0vYFIpBQyj1f7bdOIXB5PYC wG6zsbsQsxU0+ocXedIXGLzDV54ed+1I5AFDcviZCGZUOBAPWWimTnOLN9/YeW4ysGd1 f7/A== X-Gm-Message-State: AOJu0YyZG/xKOfb13jJJez1Qgqfb/zT348UkCJmkYvmQg1cHShnL0XNj 05Nid3TYJqSRuLAaCa49//u5gDs6kxcP44QAzWugHUj13LIVmwI45SZeYXVqQVAPg5GB+p3Tfa3 AFobWIcdU4YRKZkjekqg8ya7X8VfuFt+NyRxFQXMDgdHVNmh8XAYSsQmGqXZ/OcO9s0LniGMuDP 6ZTi+EHN4rAD/RTtFG X-Received: by 2002:a17:903:1210:b0:1d4:4ae9:a23d with SMTP id l16-20020a170903121000b001d44ae9a23dmr55700plh.57.1704344779784; Wed, 03 Jan 2024 21:06:19 -0800 (PST) Received: from vertex.vmware.com (pool-173-49-113-140.phlapa.fios.verizon.net. [173.49.113.140]) by smtp.gmail.com with ESMTPSA id z3-20020a170902ee0300b001d3561680aasm24505803plb.82.2024.01.03.21.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 21:06:19 -0800 (PST) From: Zack Rusin To: linux-kernel@vger.kernel.org Cc: Zack Rusin , Dmitry Torokhov , Arnd Bergmann , Robert Jarzmik , Raul Rangel , linux-input@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] input/vmmouse: Fix device name copies Date: Thu, 4 Jan 2024 00:06:05 -0500 Message-Id: <20240104050605.1773158-1-zack.rusin@broadcom.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127204206.3593559-1-zack@kde.org> References: <20231127204206.3593559-1-zack@kde.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783751786082315107 X-GMAIL-MSGID: 1787135065669481715 Make sure vmmouse_data::phys can hold serio::phys (which is 32 bytes) plus an extra string, extend it to 64. Fixes gcc13 warnings: drivers/input/mouse/vmmouse.c: In function ‘vmmouse_init’: drivers/input/mouse/vmmouse.c:455:53: warning: ‘/input1’ directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=] 455 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", | ^~~~~~~ drivers/input/mouse/vmmouse.c:455:9: note: ‘snprintf’ output between 8 and 39 bytes into a destination of size 32 455 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 | psmouse->ps2dev.serio->phys); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ v2: Use the exact size for the vmmouse_data::phys Signed-off-by: Zack Rusin Fixes: 8b8be51b4fd3 ("Input: add vmmouse driver") Cc: Dmitry Torokhov Cc: Arnd Bergmann Cc: Robert Jarzmik Cc: Raul Rangel Cc: linux-input@vger.kernel.org Cc: # v4.1+ --- drivers/input/mouse/vmmouse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c index ea9eff7c8099..74131673e2f3 100644 --- a/drivers/input/mouse/vmmouse.c +++ b/drivers/input/mouse/vmmouse.c @@ -63,6 +63,8 @@ #define VMMOUSE_VENDOR "VMware" #define VMMOUSE_NAME "VMMouse" +#define VMMOUSE_PHYS_NAME_POSTFIX_STR "/input1" + /** * struct vmmouse_data - private data structure for the vmmouse driver * @@ -72,7 +74,8 @@ */ struct vmmouse_data { struct input_dev *abs_dev; - char phys[32]; + char phys[sizeof_field(struct serio, phys) + + strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)]; char dev_name[128]; }; @@ -452,7 +455,8 @@ int vmmouse_init(struct psmouse *psmouse) psmouse->private = priv; /* Set up and register absolute device */ - snprintf(priv->phys, sizeof(priv->phys), "%s/input1", + snprintf(priv->phys, sizeof(priv->phys), + "%s" VMMOUSE_PHYS_NAME_POSTFIX_STR, psmouse->ps2dev.serio->phys); /* Mimic name setup for relative device in psmouse-base.c */