From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 22970C76195 for ; Fri, 19 Jul 2019 04:08:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E469E2189E for ; Fri, 19 Jul 2019 04:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563509327; bh=Kv4dAL8DwB38AMp1Ja0QC7CQHWK0A5JvIj+UwchxZbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=plaptgT54qtd2YElrkQPVEZ/rlqq15w9BW3FX6PgXgc2yhBvFYMniHVBvbCa6MVOe IJNEXI5AJsfWJMQGUuE/O+hZ29AByehqfs+xgCmOKRVHIEujI6lEaE4oqRpADukSeL OzZTJWYGPKlFqMyjBnrJ5Av3UyyoJP5LGmZvxwLw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731684AbfGSEIp (ORCPT ); Fri, 19 Jul 2019 00:08:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:43112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731912AbfGSEIp (ORCPT ); Fri, 19 Jul 2019 00:08:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32073218BB; Fri, 19 Jul 2019 04:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563509324; bh=Kv4dAL8DwB38AMp1Ja0QC7CQHWK0A5JvIj+UwchxZbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4sWlzB+nhV1gApmPpGgAHnz4PN0Zw+aFWTqueq9CdoowSAKx3ymAKc+wmTHNCtYI QbW/BhP0+AwH2EGTbC23jZiLpcJxlr8SAjzdyePoZrGyI84kPrlLYH/qC67V1WlOvb UoAO/U4sn42nxcDmgeWDyUh3lOMuYJaJnUbcGhxU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrzej Pietrasiewicz , Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 035/101] usb: gadget: Zero ffs_io_data Date: Fri, 19 Jul 2019 00:06:26 -0400 Message-Id: <20190719040732.17285-35-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719040732.17285-1-sashal@kernel.org> References: <20190719040732.17285-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Andrzej Pietrasiewicz [ 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 aa15593a3ac4..2050993fb58b 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1101,11 +1101,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; } @@ -1137,11 +1138,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