From patchwork Tue Jun 18 07:44:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Banajit Goswami X-Patchwork-Id: 11001129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 055F3112C for ; Tue, 18 Jun 2019 07:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB286289B5 for ; Tue, 18 Jun 2019 07:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF77128A0E; Tue, 18 Jun 2019 07:45:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 28E0128A08 for ; Tue, 18 Jun 2019 07:45:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 74E7616DB; Tue, 18 Jun 2019 09:44:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 74E7616DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560843918; bh=toGhPdUV/ki9GSH7XPY/pxIzpDoa5wnw8GTtKc15xWw=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Xg22U2fTpqymw1aUSE2xa/1am7035di2nlWVs/Yf6Y0wi6+BoR4ulEBdytPmUjYJX 6P2o7ptPQl6gu/1QpWFbFTbiXiRbrZ7HHyGuS+RGCtz/TTFwaumxcnxskS/sD5KLG8 qLv47jVXSGWBZxtkT41s5AXcHYfCoaYsxZB46cXU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F2836F896DB; Tue, 18 Jun 2019 09:44:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 726DBF896F4; Tue, 18 Jun 2019 09:44:26 +0200 (CEST) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D2E0FF89682 for ; Tue, 18 Jun 2019 09:44:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D2E0FF89682 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="IBqmOjSp"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="IBqmOjSp" Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BB3B0602DD; Tue, 18 Jun 2019 07:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1560843861; bh=atQUjk4vum7dZNgFC1o95VNme1jXzGjB71O94ioK+qo=; h=From:To:Cc:Subject:Date:From; b=IBqmOjSpmj9DQFtfv9SdZlJ0UMK2FIA0/CB3S42NlrizP9hWB0Z8COev13nYsEzfR hCdahItC/RwoLCbYi7A94Ms5hZdqf0cA1uukuGgFusaxc/ONEM5qIrORf53hljgzEv B0PyWuOsGz2gBuhSrOkfJiryp10b914VAed8cjz0= Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: bgoswami@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3501260300; Tue, 18 Jun 2019 07:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1560843861; bh=atQUjk4vum7dZNgFC1o95VNme1jXzGjB71O94ioK+qo=; h=From:To:Cc:Subject:Date:From; b=IBqmOjSpmj9DQFtfv9SdZlJ0UMK2FIA0/CB3S42NlrizP9hWB0Z8COev13nYsEzfR hCdahItC/RwoLCbYi7A94Ms5hZdqf0cA1uukuGgFusaxc/ONEM5qIrORf53hljgzEv B0PyWuOsGz2gBuhSrOkfJiryp10b914VAed8cjz0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3501260300 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgoswami@codeaurora.org From: bgoswami@codeaurora.org To: vkoul@kernel.org Date: Tue, 18 Jun 2019 00:44:06 -0700 Message-Id: <1560843846-4631-1-git-send-email-bgoswami@codeaurora.org> X-Mailer: git-send-email 1.9.1 Cc: Dhananjay Kumar , alsa-devel@alsa-project.org, Banajit Goswami , plai@codeaurora.org, tiwai@suse.com, srinivas.kandagatla@linaro.org Subject: [alsa-devel] [PATCH] ALSA: compress: avoid integer overflow for long duration offload playback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Banajit Goswami Currently a 32 bit variable is used for storing number of bytes copied to DSP, which can overflow when playback continues for a long duration. Change data type for this variable to __u64 to prevent overflow. Signed-off-by: Dhananjay Kumar Signed-off-by: Banajit Goswami --- include/uapi/sound/compress_offload.h | 2 +- sound/core/compress_offload.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index 56d9567..db5edf3 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -67,7 +67,7 @@ struct snd_compr_params { */ struct snd_compr_tstamp { __u32 byte_offset; - __u32 copied_total; + __u64 copied_total; __u32 pcm_frames; __u32 pcm_io_frames; __u32 sampling_rate; diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index a1a6fd7..2d0a709 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -184,7 +184,7 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream, if (!stream->ops->pointer) return -ENOTSUPP; stream->ops->pointer(stream, tstamp); - pr_debug("dsp consumed till %d total %d bytes\n", + pr_debug("dsp consumed till %d total %llu bytes\n", tstamp->byte_offset, tstamp->copied_total); if (stream->direction == SND_COMPRESS_PLAYBACK) stream->runtime->total_bytes_transferred = tstamp->copied_total;