Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3798976ybi; Mon, 29 Jul 2019 12:51:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ96UwZHhR2XigeDTnrW3HDNSdn0j27uwZFqan8d0rp9h5rOGaltlyCM3Y9vHzYcatWbMD X-Received: by 2002:a62:187:: with SMTP id 129mr38583379pfb.128.1564429885139; Mon, 29 Jul 2019 12:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429885; cv=none; d=google.com; s=arc-20160816; b=uPSA54C5rbRrNDEh5+PpP3R+iXNjnS7kYWJBgNBacNvTarl1a5S1LWye/5uwtbPkSM M5uGcrA/KI9Y08DiebTdLbNphX0nooWFeOi6TKtxshNpRufyvhT6IlCDJLv52/Q8g/nL BzQ+igO6zft8nr1moIPMT05B7W1PkrNet2Ak4CYVyWxsUf+I52SASE8LWyr/UWdQkTjZ SNmUq7pNedU/5ZjW0pZWL7//X6u68oJALSTp74XchVDPNEIQRh+qnOCJfgdobMnJNS3u 74D6rBQoXec8Q6q0rsgzJeJZw7YR6/U9FQS8z+hrsfgr8qnqg4bkGBq1DVlomwKhiQZA Sp0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=91HKIVUIdrdIYv/atvts6MoiSqBk2qY1/rtPS4r+XZ8=; b=yoJyuwDapoqjmhbiMwb/sXjOo7zxAi/mI/KQMlMi8iBdy2vIV984id7TFRsHccoAul 4FkPYATZpD23PgdyVJUzuGg3B9JwUiR1QyfI6pqv8SPk2Uj2D0bnymv9nqLAvtN2gpqK 6nkp/HzEnklP/zsbgV4vxhNJAANHElGfq1x+Na8zVe0uy6Z/wJDSV8BUBXjcr5TuZ/mU G90ZewllifuqRA8DI+WPGhnHjlqr5i/pQlK7SWB3QLLH6U8lAMfxWJ+f9wq1C03rhf3A JHnnuXAQ5cOjgnr6QjKImisQqcPN/LL9nUheOgdQqxDdfbJsFnGHCvI4SGxNHAYVAs3v bjRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="k3tH/Stv"; 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 j16si15475192pfh.0.2019.07.29.12.51.09; Mon, 29 Jul 2019 12:51:25 -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=@kernel.org header.s=default header.b="k3tH/Stv"; 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 S2390222AbfG2Tsi (ORCPT + 99 others); Mon, 29 Jul 2019 15:48:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:38904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390133AbfG2Tsh (ORCPT ); Mon, 29 Jul 2019 15:48:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 084032171F; Mon, 29 Jul 2019 19:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429716; bh=2wxzt5JMsqqpQOcd2Ku1eTy6OT7lVsReh/kZknImlaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3tH/Stvj4Mz6yVvKbr0motY7fodWwi6u+FjW5SE1C0y75NAeCNhgy+fXciz+hKQx vui0Yb5Dvtn5dGsZUso4/kAJYiqa6t8GGN5fjKfjIcl4etWMqXAXM1mvVsW45OulMO qog1C6Qxy20fbLIsZ2urkQT4nhP3ryK9qxtgE/Ro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrzej Pietrasiewicz , Felipe Balbi , Sasha Levin Subject: [PATCH 5.2 070/215] usb: gadget: Zero ffs_io_data Date: Mon, 29 Jul 2019 21:21:06 +0200 Message-Id: <20190729190752.430092823@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 508595515f4bcfe36246e4a565cf280937aeaade ] In some cases the "Allocate & copy" block in ffs_epfile_io() is not executed. Consequently, in such a case ffs_alloc_buffer() is never called and struct ffs_io_data is not initialized properly. This in turn leads to problems when ffs_free_buffer() is called at the end of ffs_epfile_io(). This patch uses kzalloc() instead of kmalloc() in the aio case and memset() in non-aio case to properly initialize struct ffs_io_data. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index c7ed90084d1a..213ff03c8a9f 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1183,11 +1183,12 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from) ENTER(); if (!is_sync_kiocb(kiocb)) { - p = kmalloc(sizeof(io_data), GFP_KERNEL); + p = kzalloc(sizeof(io_data), GFP_KERNEL); if (unlikely(!p)) return -ENOMEM; p->aio = true; } else { + memset(p, 0, sizeof(*p)); p->aio = false; } @@ -1219,11 +1220,12 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to) ENTER(); if (!is_sync_kiocb(kiocb)) { - p = kmalloc(sizeof(io_data), GFP_KERNEL); + p = kzalloc(sizeof(io_data), GFP_KERNEL); if (unlikely(!p)) return -ENOMEM; p->aio = true; } else { + memset(p, 0, sizeof(*p)); p->aio = false; } -- 2.20.1