Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3012822rdb; Mon, 4 Dec 2023 14:07:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwnwKjekVhsVqvXDIw3iDydSYwMB8UwknrXzrArb5wp8HTauVUcubRqOQelU6BM2dFNFui X-Received: by 2002:a05:6a21:1a9:b0:18c:6c2:5369 with SMTP id le41-20020a056a2101a900b0018c06c25369mr2347208pzb.30.1701727643938; Mon, 04 Dec 2023 14:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701727643; cv=none; d=google.com; s=arc-20160816; b=PdlRw2xYmTDlrcIQLaDFhjnG2pZbt81lkSYBAwzymSTiPkzs8/W5hwH++oVWkKuhj4 Tg+f5FI3w7VWOUJ/ABZplD3jbpvP7PqfompZ+T5c4E2trX7GNnWOj52uENsrxO+U02m8 PWB0u5GGjz6Rl7mKjZ6nAFOdl+CJNChpBKUdaHt864P5UHebuIOIQ4dnslBV7BGIFYO4 dulcYsb4qppJw09hUAcofHQv5UvEb3fRVGRymkrMgnG02eHg7HTuB6yDYhDb+eeMqiGp EphcYD+Yf9Q7++hNS0XqhQT/tLwtrCTSj6nUmMv1RBwt/Rrjme2TzPvW5fV8StR8n/+v ucCQ== 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:message-id:date:subject:to:from :dkim-signature; bh=GZxuHDLHq/7J9eWN8ZsQmRte/LPyVEp6v3+CgTDZ1ZE=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=W4b2hS+PSvd2B78elmVUChbeic4WwRbPU93ZlcOiqClfXdAp3wC8OLetLMW+bQ8iGh JDJv7TeNicbGQVShFVzdZMObUunwMtPJhXysKmn4e7rSWFY8PYbWu3L1h+xOUUXM2fWL 7zcBE3O1hbVKbsTL7ZX8fbvi8Wrj9K3Aitb19uXfhmLc/LSYfwJNhK7yFqDjgrjMBDfI vMcFjeJBFcJIDRSheasVxPMrNXHPyVGwjq+R4c83diN4PAV5Gr9AbQWbGalvTMMvEtD0 StvB8B6Y2GYypOSsXrZAmXNi5FzpMGQqzIz8rIdJlfIsY2W+4bJm6dT8aCsk7TzBZ65P 5gcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HBOcAmrk; spf=pass (google.com: domain of linux-bluetooth+bounces-374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y67-20020a636446000000b00578b9fb24f6si4432307pgb.616.2023.12.04.14.07.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 14:07:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HBOcAmrk; spf=pass (google.com: domain of linux-bluetooth+bounces-374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CD1B92812E8 for ; Mon, 4 Dec 2023 22:07:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA44E39FFE; Mon, 4 Dec 2023 22:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HBOcAmrk" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913FC10F for ; Mon, 4 Dec 2023 14:07:15 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-77d6b28aa9aso343833285a.3 for ; Mon, 04 Dec 2023 14:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701727633; x=1702332433; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=GZxuHDLHq/7J9eWN8ZsQmRte/LPyVEp6v3+CgTDZ1ZE=; b=HBOcAmrkS+/3rHO2qmeTr/hhcNHk24hKy3Ms6cZ3wrgonrQKSUz1/WUhKnyNCPuiEY ZSvj+MxeZVHHLLOTClkgzOibzKHrieiTaFS+PWkRDdCULMcq8hR96I1DlXh4rozfE+H6 F8DksKCosMo+8gbmPVFj0UmsUzuPjr6sp7X5PJ0Cxn+YQPvb9pDqAka57L0m7WTW8EEL aWJRMiyW3jQ/SvHCow/jB5eZUJX3GWsg8Ppl2Dqgrw7HKFgOFmoRKrOZrYspUwZ0BzVy LQZ08UK4qWcWJU0NgaHvplmfX4RcBlx5vs0AN2kjsoR5ZaYE5OW2yLSJzrh5bjUU0vns G2Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701727633; x=1702332433; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GZxuHDLHq/7J9eWN8ZsQmRte/LPyVEp6v3+CgTDZ1ZE=; b=AVEgB8I8bN/Of8SvMIKaqnmoypuPCoz06bibfHkdzOZ3qsFgm911zWtFtjKkoikmAi GjIepIG4ruiWJlItfnMUEHZOCxt4yPps78AkNxTanY71SzDDKgyW4z4CWehLuQiT3rY/ MuuZbGliFuozQgAx7MUDHSEsnj1dHj1Ur5SV/obQuI+kx3CsuA5O7ecUEkC/Mxa0g3De lrZsqAyFNeIijtbgQNJ1livI3BTnQ+3zPvYGUlDZTTqmofU+aMRCtZuoxv2LXxe1P70g C2MCICuwRGB2qpFFWXxUXZLvPGiIJbR/rRyI8/1TSwKhlIdl4/2YS3FhMKyR96WikrM7 Lwng== X-Gm-Message-State: AOJu0Yxela/igdg5jRmiddPmBqjEHNwEiS2HZgYl+CVYxqsj0T+bRG7X E9MSHq7BTPB6XtMCpYQGG6dmgUxK/Gk= X-Received: by 2002:a05:620a:8181:b0:77e:fba3:81e3 with SMTP id ot1-20020a05620a818100b0077efba381e3mr248584qkn.121.1701727633482; Mon, 04 Dec 2023 14:07:13 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id bp9-20020a05620a458900b00767d4a3f4d9sm4566903qkb.29.2023.12.04.14.07.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 14:07:12 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1] shared/vcp: Fix comparison of values in different endianess Date: Mon, 4 Dec 2023 17:07:11 -0500 Message-ID: <20231204220711.2974630-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz Values received over the air are in Little Endian format so they first need to be converted to host endianess before comparing with other values. --- src/shared/vcp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shared/vcp.c b/src/shared/vcp.c index 06a22997a95c..5d163266b480 100644 --- a/src/shared/vcp.c +++ b/src/shared/vcp.c @@ -709,13 +709,16 @@ static uint8_t vocs_set_vol_offset(struct bt_vocs *vocs, struct bt_vcp *vcp, return BT_ATT_ERROR_INVALID_CHANGE_COUNTER; } - if (req->set_vol_offset > VOCS_VOL_OFFSET_UPPER_LIMIT || - req->set_vol_offset < VOCS_VOL_OFFSET_LOWER_LIMIT) { + vstate->vol_offset = le16_to_cpu(req->set_vol_offset); + + if (vstate->vol_offset > VOCS_VOL_OFFSET_UPPER_LIMIT || + vstate->vol_offset < VOCS_VOL_OFFSET_LOWER_LIMIT) { DBG(vcp, "error: Value Out of Range"); return BT_ATT_ERROR_VALUE_OUT_OF_RANGE; } - vstate->vol_offset = le16_to_cpu(req->set_vol_offset); - vstate->counter = -~vstate->counter; /*Increment Change Counter*/ + + /* Increment Change Counter */ + vstate->counter = -~vstate->counter; gatt_db_attribute_notify(vdb->vocs->vos, (void *)vstate, sizeof(struct vol_offset_state), -- 2.43.0