Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3133538ybi; Thu, 18 Jul 2019 21:41:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxETTW2O+kzAeNi5PnsXdw0E2Uap6wIgweGo0VY/pA0kRAbbrDHJ1pMa9dvwiHIFbhvs4o9 X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr54824942pjz.140.1563511271464; Thu, 18 Jul 2019 21:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511271; cv=none; d=google.com; s=arc-20160816; b=BmY184GrpuyBBnvxlLlOaPmCI9G2JaU5MXkVVX5ZqZdACOxoB85Q4p1YJ4unSuIfLU f5x7lTdwkLxudBmTDUSFGan5Wo+fdSnt0QLo9fTrVPhPYvuKhl6w5XPivBn/TzXsjGJX mu6cjsLcBhW9ZrCWaWeJYMFPOYVZfI6HKfuUGNc7FUVKHb1XCA0DuQ+Yh5cWViLnP65j Yt8wB+us43wzziQJcBG7QmmJYfo9NmSiTAQQ4l7GpN4uVKV1ROOGhoOdLbIelwjTXUYg peP9NQzEXt9ye+TRCA7JZdsagSk+7BiN2CfF/e2QXhrqMYWDsbrPhNbsjiSsoHzZHw1+ tupQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rc5IfVAhLhgMKcE04+MATYqD39zxHj17vKYIpjWXZM4=; b=Ma0l054aQ4te1yqu5qrWrZOiqPQsCeMDC3X96HUwfNKDQNfYEhES/0Fz9w0H95k+AT VPe/Xzx2fhYu3Bk9QliB2e8QACUdsrV6GX72UUulyUV5C4zhWKEzbZqeBlv/HuZwNhf+ qYuyhBzkrKTohToD5acftRyZ1FxIXN4B4YaBV4YeWzPN9Zj3R9eH8J7+l0YpOft94r/d K4PLtrJ4SriYnd43FQC+Svmc+WjV706qXRM0fWPA9ac7UcbGoHD1yMgRbZJPWoti8EoF n7sHKrihtAnKzfiZZgwohhvq+UR9RTtKYRT03bp9zZrW6etE1eTfNUnj2PRCTM+Q3Dsc upvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BgcXDqXf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si3175830pgb.503.2019.07.18.21.40.55; Thu, 18 Jul 2019 21:41:11 -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=BgcXDqXf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728606AbfGSD7R (ORCPT + 99 others); Thu, 18 Jul 2019 23:59:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:58654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728536AbfGSD7L (ORCPT ); Thu, 18 Jul 2019 23:59:11 -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 D3AA921851; Fri, 19 Jul 2019 03:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508750; bh=IgqLmc9gab5vB2kgwbuIUQkckeqHIN4ozj7XkneYH2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgcXDqXfRY8R85dPekvsMWFBRXe1oxhHqyjg1ldzAYxhM49C6PPcDSHGuFa7yld+Y yYh9YOqNISmUebB78uNWrf4UPbwN2L53hQ8z0O5C3xRSk55cU33pKir6jfy5jIs+5+ iAHjOZ3T1pjQWQvhqSk3/aJag4GrTIuaWINQYKs4= 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 5.2 069/171] usb: gadget: Zero ffs_io_data Date: Thu, 18 Jul 2019 23:55:00 -0400 Message-Id: <20190719035643.14300-69-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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