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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 AF9DCC433FF for ; Mon, 29 Jul 2019 19:36:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B6F3217F5 for ; Mon, 29 Jul 2019 19:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428965; bh=96GKdQd01LTKAbHkpgUaJiy124ivuRtEJ2BvWn9+DOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pmiSCuY7g7ews1khaevftQWgm6KEA74CvX7TnLdFsMYfbr9NQ/mtmNmPndMbkLHEi o4lhl+DO6ibiJZ9GGVuIWKdDxRQN3ZbaYTmKRQuEMVpPAuLyT2ldMdQBOLNwI/FmxK mF6OHWU456yR+LdT9GEoT3GhoWJPPO7RyPSaRAnQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727796AbfG2TgE (ORCPT ); Mon, 29 Jul 2019 15:36:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388412AbfG2Tf7 (ORCPT ); Mon, 29 Jul 2019 15:35:59 -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 B99502070B; Mon, 29 Jul 2019 19:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428959; bh=96GKdQd01LTKAbHkpgUaJiy124ivuRtEJ2BvWn9+DOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTyaLmx3BjVX4Lb4mR06bmuXSmhE+rRZ5Yscby1SmlzD+jCfIe+v7Gf+08PBoDKAW TZxzLKLySLT4hJhP3ANLwd4plT9e96ILaUWMR9A2EunWRKBdYQBpz+wqn58ntbXJWq nxgdSnro5+CwiaSijqLfbbiWa0yapI84qGrGmoJw= 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 4.14 241/293] usb: gadget: Zero ffs_io_data Date: Mon, 29 Jul 2019 21:22:12 +0200 Message-Id: <20190729190842.931624396@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 79900c0b4f3a..cdffbe999500 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1102,11 +1102,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; } @@ -1138,11 +1139,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