From patchwork Fri Apr 2 11:42:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12180783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42E58C433ED for ; Fri, 2 Apr 2021 11:43:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9566F6108F for ; Fri, 2 Apr 2021 11:43:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9566F6108F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 3AAC116AD; Fri, 2 Apr 2021 13:42:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3AAC116AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1617363805; bh=3bsgKcvW987Hx/vJ+hlwBPyLqwXdRxkj3ysSMkVXCEE=; h=Date:From:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=CIpJ0TISNQLJUcVzWsgMvVTD63CBhijFobneQJheq42w0j/Xbcu+xiqgc7LIzE7jo 14LtCOn5EagcZg6IH++SsvnkvY98fuGxDky0Ezop7DoAAjg7cdg1ViSZ7sbUOAH7XZ zXf5MoeBBouewNBmMjhed9Y8yYtWHPXti/3lSeng= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AD83AF8016E; Fri, 2 Apr 2021 13:42:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 566D1F801DB; Fri, 2 Apr 2021 13:42:33 +0200 (CEST) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 437AEF80166 for ; Fri, 2 Apr 2021 13:42:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 437AEF80166 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KPbKe9VO" Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 132BcX2M073984; Fri, 2 Apr 2021 11:42:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=ao9U5dvQsdaWV9YstHzsV5gFgSLEsPBaL2W+rjkc2DE=; b=KPbKe9VO7b28z93J8Po73/yN04BzK/e7U82onSYwDo9pJQB5IPuY3B0jCeXfT+FrF7Nl HSJCKLJRoFqk7Wn/tPKi3q0sZY3dKCS2Vm77sMMTVxpDo1IQKcjHwZt4BrtzNRBtPgvm 1tx2Yno5d7puuoLMWM3GIHK/WUOQB0BwSoX78pIsjMVhtiLkYhGkVGxV0gsDhhe9ZuFg tsrT+CmvVg6g75dJsoByUdYp55sojbP3X6Nxxd9R0DKbUvWuK4b3mJAMYj5WnsD7xMNL 7msM8fke+s2LA8nOyCcT9JRwLjTjJh4OLoW6UlwYttXX6tYp/7+cdFzexeaiYOBERQIZ Wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37n2a04fq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Apr 2021 11:42:25 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 132BdejO037091; Fri, 2 Apr 2021 11:42:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 37n2atyqwd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Apr 2021 11:42:24 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 132BgGWQ000859; Fri, 2 Apr 2021 11:42:20 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Apr 2021 04:42:16 -0700 Date: Fri, 2 Apr 2021 14:42:09 +0300 From: Dan Carpenter To: Jaroslav Kysela Subject: [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9941 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104020086 X-Proofpoint-GUID: cs-X96M9uQD64jsfNcc7ZHGwnWV4nsPk X-Proofpoint-ORIG-GUID: cs-X96M9uQD64jsfNcc7ZHGwnWV4nsPk X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9941 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 bulkscore=0 priorityscore=1501 spamscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104020086 Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Takashi Iwai 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This unwind loop needs to free snd_ctl_leds[0] as well. Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module") Signed-off-by: Dan Carpenter --- sound/core/control_led.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/control_led.c b/sound/core/control_led.c index d4fb8b873f34..202b475d0bf3 100644 --- a/sound/core/control_led.c +++ b/sound/core/control_led.c @@ -712,7 +712,7 @@ static struct snd_ctl_layer_ops snd_ctl_led_lops = { static int __init snd_ctl_led_init(void) { struct snd_ctl_led *led; - unsigned int group; + int group; device_initialize(&snd_ctl_led_dev); snd_ctl_led_dev.class = sound_class; @@ -730,7 +730,7 @@ static int __init snd_ctl_led_init(void) dev_set_name(&led->dev, led->name); if (device_add(&led->dev)) { put_device(&led->dev); - for (; group > 0; group--) { + for (; group >= 0; group--) { led = &snd_ctl_leds[group]; device_del(&led->dev); } From patchwork Fri Apr 2 11:42:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12180785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA5E7C433ED for ; Fri, 2 Apr 2021 11:44:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7262610D2 for ; Fri, 2 Apr 2021 11:44:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7262610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 DFA5116B6; Fri, 2 Apr 2021 13:43:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DFA5116B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1617363856; bh=akv+ego+Vr6ANURpuVu9YV5cG4pV06VIlHU55k16Zq8=; h=Date:From:To:Subject:In-Reply-To:Cc:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From; b=FkokJncW8D0c5yXY+nuHr98gnmmSwaM3DjADxh/n3m/NMwXvn3jFaO46RRbSZ33U6 w92e5Qos39mIOZmTg65+wxENNq06aDeZxvvCX0Cw3S/vq9OSsxJ/eJs/XL/EjRKuOY RpSShILFHZ6UAe0vxmUazIXHn3Z1Kl8CESmvsx60= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 74FFEF80254; Fri, 2 Apr 2021 13:43:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B3995F80259; Fri, 2 Apr 2021 13:43:07 +0200 (CEST) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F006BF800F5 for ; Fri, 2 Apr 2021 13:43:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F006BF800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HeiPHFaH" Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 132BdKGY176909; Fri, 2 Apr 2021 11:43:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=f2Qqg+QdMNEJAsl63Sldfs/x8lzeMiNgw6E8mw1zqCE=; b=HeiPHFaHVAC7GW42AU7dXVdBbJ4x3rTNTzbGM1M+I81isT8ykXAqk+MRK+pIDVIPTSJ7 BOYAHLjoABcAj35jKp7Utuczv9heOiz/sNtskAUzUvWeeE9AlypbPG/5nOTEBABXE2td H/qd9xYpZE1FaT1JmJLQOkr3gau63o5J2EzDasACWzRvAx6t5MDjj1iKSmhg50BJU803 P48U6qzFIuQU6p6Rd3ITN1kQtmqUe/nw5qdN6A2dMxBahgC7gpMvPIZq+qdY1WYdnr1I Mx56OgjLr5rTIYuhLirbyfVgA45UPAIX/H5fPUxJ8gS2HewT0gDqVMdioJPJZ6czskUo SA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 37n30scdnw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Apr 2021 11:42:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 132Bf0UL140619; Fri, 2 Apr 2021 11:42:58 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 37n2accncn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Apr 2021 11:42:58 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 132BgvqY011345; Fri, 2 Apr 2021 11:42:57 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Apr 2021 04:42:56 -0700 Date: Fri, 2 Apr 2021 14:42:50 +0300 From: Dan Carpenter To: Jaroslav Kysela Subject: [PATCH 2/2] ALSA: control - off by one in store_mode() Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email haha only kidding X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9941 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104020086 X-Proofpoint-GUID: FHcbwHGHBFOgQDpOJm-8le-T87M0f9wr X-Proofpoint-ORIG-GUID: FHcbwHGHBFOgQDpOJm-8le-T87M0f9wr X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9941 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104020086 Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Takashi Iwai 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" If count is 16 then this will put the NUL terminator one element beyond the end of the array. Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module") Signed-off-by: Dan Carpenter Reviewed-by: Jaroslav Kysela --- sound/core/control_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/control_led.c b/sound/core/control_led.c index 202b475d0bf3..ab5a455723c8 100644 --- a/sound/core/control_led.c +++ b/sound/core/control_led.c @@ -391,7 +391,7 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *attr, { struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); char _buf[16]; - size_t l = min(count, sizeof(_buf) - 1) + 1; + size_t l = min(count, sizeof(_buf) - 1); enum snd_ctl_led_mode mode; memcpy(_buf, buf, l);