Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5675581imm; Mon, 23 Jul 2018 04:12:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpffWXvQiUUfRod1lGrv31x3CXjp4ChEEfg0HVpYDmvbMmM/OqNqRSieG2sp/6OJPY1sDATo X-Received: by 2002:a17:902:8a90:: with SMTP id p16-v6mr3666521plo.106.1532344320666; Mon, 23 Jul 2018 04:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532344320; cv=none; d=google.com; s=arc-20160816; b=GYOQAM974VzGdLFYSNfvU0wLzLN4pkXwkYor/MaYSUeqkFOwsRwoEVmKZC5InMI2lK QBDgWbvGw4psqVTEa0xXpHIU1dkmKwPtvI4kwYn1wPDE1EHwOsN0BY4bH0lVExtKCtZ5 QiO460ydd1FDS6y97TlBg9bQPLlbUPrxZqI3BZe4tfROIrG3jpxm8cyIAm77SimBj2Sr vJ8FfHSJ6fwG6uBkeQvH7vKCukeYHBKRK1LNRF+8kkiY+LtXHmEVs5DJhH8E9MoQwKNK K4+Q5GGdzkMowTywB6xPzD3nIt3oeVsc07QFrHtMyS5zR27e34cqQ6hsCep/EC2wBGYW Dfhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=+v29pUSID7u/mFVYhevBsLWOuxfFL367mhA7UaJDGRM=; b=dNqbJIamWkg3LxmEeCBF91pfD/5CV2b1SQUtOw/bpZGeEaHXtGTHFxeFyTHBHkajoh KVnipqH9cbXJ1aE72nwf+lbQtewUE91mr/EIEhDK3xljRIobHCD2gH86bMclEvEOKD8d 1navyfRxqh2cY5q/+rlCmsqte24EKb1MTdm5wzGUMdHGVzLoveF4UOJBWaRZZ4hEXlWe 1qc15T2TImoaJ8anxg0fvwDm6Sb9Ir+HeZzOsSA+oZJAFo9YAJQ3Niz3S1c6QeO8Yd3n ELT694z0gWIeAbAIWMojEF/+Fg1RPTA82VpWVkUKyBrwpy4em9tHVg3NI25MXVt/Mbcj j6yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=YiKZQSAy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x17-v6si7965975pfn.286.2018.07.23.04.11.45; Mon, 23 Jul 2018 04:12:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=YiKZQSAy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388043AbeGWMLA (ORCPT + 99 others); Mon, 23 Jul 2018 08:11:00 -0400 Received: from m12-16.163.com ([220.181.12.16]:51197 "EHLO m12-16.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387970AbeGWMK7 (ORCPT ); Mon, 23 Jul 2018 08:10:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=+v29pUSID7u/mFVYhe vBsLWOuxfFL367mhA7UaJDGRM=; b=YiKZQSAyV80TUyN2G1+o6kJsDEOo2GwkbO 0VeHJEQFhYgdSpCvpLK7Wryq0LqLJ55GwhBvSjpPMjNHCeTYXDYU0VGOqJCDA9yK Jphs+zcXBE/YzNUUk5yKnbN/0YaLlldqOxCL7+sShDzwUz+doKTt/SnEo3ub8CCm nk/toGeZY= Received: from localhost.localdomain (unknown [106.120.213.116]) by smtp12 (Coremail) with SMTP id EMCowACniUaCt1VbVMRSIA--.19246S3; Mon, 23 Jul 2018 19:10:03 +0800 (CST) From: Xidong Wang To: Felipe Balbi , Greg Kroah-Hartman , Johan Hovold , Michal Nazarewicz , Vincent Pelletier Cc: wangxidong_97@163.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] usb:gadget:function:fix memory leak Date: Mon, 23 Jul 2018 19:09:46 +0800 Message-Id: <1532344186-30505-1-git-send-email-wangxidong_97@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EMCowACniUaCt1VbVMRSIA--.19246S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKrW3uFy3Ar1UCrWDAF45Awb_yoWfZFX_uw 1xXr1xXryqq3ZrGrWUG3yfAFWIga1UXF97uF1qgr9aya4S9ws3Ww1vqrs5G3WxZw43Wrn8 CryrXrnxXw4aqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8I38UUUUUU== X-Originating-IP: [106.120.213.116] X-CM-SenderInfo: pzdqw5xlgr0wrbzxqiywtou0bp/xtbBFQuM81XlcX044wAAsG Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function f_audio_set_alt(), the memory allocated by usb_ep_alloc_request() is not released on the error path that req->buf, which holds the return value of kzalloc(), is NULL. This will result in a memory leak bug. Signed-off-by: Xidong Wang --- drivers/usb/gadget/function/f_uac1_legacy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/gadget/function/f_uac1_legacy.c index 24c086b..2fcdade 100644 --- a/drivers/usb/gadget/function/f_uac1_legacy.c +++ b/drivers/usb/gadget/function/f_uac1_legacy.c @@ -630,8 +630,11 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ERROR(cdev, "%s queue req: %d\n", out_ep->name, err); - } else + } else { + usb_ep_free_request( + out_ep, req); err = -ENOMEM; + } } else err = -ENOMEM; } -- 2.7.4