Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4056362ybi; Mon, 29 Jul 2019 18:19:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4jvCT7c0B4xKlTy6b9auWGszY0Z9nkgYUofTLMchMeOd1Q6C3TWnzSg9VsTMhHxMiVa3n X-Received: by 2002:a65:5202:: with SMTP id o2mr82491255pgp.29.1564449577409; Mon, 29 Jul 2019 18:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564449577; cv=none; d=google.com; s=arc-20160816; b=XhOBv3Ad+S87KRpLGpgCChsXvhb0002IQC1yOSBtPaVE7/+OS5YGoWxTnM5w/e3Pf4 ekYX/53UQz1RsBykOc807T9LCWc6x71RLHL6LkZ4E1Tc5yKt/y8AvagJg73CqCm9F4yf KBLISqqoAQF53nC9BKf9KqggDJjzakJfP00FSPnm21XWEDzU8xTdvKsKB7FRgXyeZHvG vdsrWmy7aHOikcQVXyCOxsJ5DL1zWIGVSYaYTIXY0tNMKvkr3cAiuk2AW/r3vlhNTG2A wj3jiopW3j0k14oEpRcxgtw7E5yPX025H5gpE5LBvLpZe0vV6MGb18gGmNfjf7VTq9/f F+lw== 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=h5cUMRP1Zcge3TbkFqg9tWpG/pck141N0q/959uzywA=; b=HlBeaxZ+GKYddUvV+jBtHqb91awPpFhtdqMcc6XsrsBUEkdqr5USOeQsB9Hib89xni cvVQOEAeijX4bZT5ItShx9DV86dAXPoRXPkRUtZHFi/3VaBAh+nM5Px9hv8QQi8wmzpm oFybz0ufkwsidisODbjmF4Shm4HBXI2yQei/2TJaZqczwv/gN9Dbg8onnUevHesdWAv1 O8O72OwlacPBRdzIBVwiZGyfzMivdroUyV+/8WjNMt0Ox2uAn5EqcSNTzHupj/pghdXk U2EP6f5IoPafchhUd2MguRZlG4pseixJ50EcY6rC6RSDMlk8BTQQOYLdIL4GRUXctxaH HYWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sTyaLmx3; 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 j7si34397368pfi.10.2019.07.29.18.18.54; Mon, 29 Jul 2019 18:19:37 -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=sTyaLmx3; 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 S1729432AbfG2TgD (ORCPT + 99 others); Mon, 29 Jul 2019 15:36:03 -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