From patchwork Wed Jul 4 04:51:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaejoong Kim X-Patchwork-Id: 10505851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07227600F5 for ; Wed, 4 Jul 2018 04:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E737C28862 for ; Wed, 4 Jul 2018 04:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB17228877; Wed, 4 Jul 2018 04:51:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DFC28862 for ; Wed, 4 Jul 2018 04:51:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932204AbeGDEvl (ORCPT ); Wed, 4 Jul 2018 00:51:41 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38527 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751831AbeGDEvk (ORCPT ); Wed, 4 Jul 2018 00:51:40 -0400 Received: by mail-pg0-f66.google.com with SMTP id b1-v6so955051pgu.5 for ; Tue, 03 Jul 2018 21:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZSMA7OU8LwXL1y7GsgQrqnHmbrrhzwqsXsznQKdrOlU=; b=LfwZgM6Or5RyXO9EXJ0gD/MiTisHKbC4Ne2Wh2dj/rIxah+eklg2ZtK6oi6XPEkG4Q Wy23KAf8i7GEb/ZD6JVPo1RV/bKT5dZ2+7+mb3JRv3kbmctl3/zYbkIlp1NqEmR0Om7i v/ocCqCmh2kUoQaem8pEzS64UNBnRb+mG3Hrog74z9BjZVAHFr1kR58IQ5hNY199Hlx7 GPyPD1VXzwXiGm8ZDyAlyvUKdJDwWyJxI3fFVOfRflgpC4DtugQx9Vk1ANufRvzy7VY1 XwKRrzjitkgD31xyM9o9M4tin7KCQm1kFDY6ZEHs4wZOK53Yu6YvlHtV5y//jcyx3fTQ g31g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZSMA7OU8LwXL1y7GsgQrqnHmbrrhzwqsXsznQKdrOlU=; b=PwZPxHjHpXOJowww159Xd/HgdK2egA2R3Sf2lOEWuSCsxdx5Wnf4VF8iR2l4aEBiiY bcLSE+zOKpmBg/clPiOggJQM0/1lTjULwXjviW5ePsImGRHQL+/Xdt7WtaT3fafocIA4 8s7tbFl9whSGWlEnEDvS7wVMQKPlaH9u+UcgXpwQBc1fsZldgT06S7T9C0irG/KJLzG3 0Sf5WdgiGIU5Of+hJWxMvRg0ZNjsCfgsRoLrSuLj+JotIp5iLeGk1lNpoVtsxQTo2fEg HlM2oP3Dl9J2tm1QesmBp8msL6xNpl/8SNYqauQD/YTD5DSfeaWk+w2WtxSFnWk//4qa UgtA== X-Gm-Message-State: APt69E0L5PVSeZxo4FaPsOrlkTNptUjI+ahhTN4m7bYuXpFGvTOoSt4z 74gtgdQPy3HsJt2UiYUxWkQ= X-Google-Smtp-Source: AAOMgpdXW0M8EKAIbGRcf0sIsBaDo7EenOz6BLv8e3YAf8b8uak0D62BlvQHFEI4WEE1Ry5S/Qd92Q== X-Received: by 2002:a62:aa02:: with SMTP id e2-v6mr544784pff.211.1530679899523; Tue, 03 Jul 2018 21:51:39 -0700 (PDT) Received: from climb.lge.net ([27.122.242.77]) by smtp.gmail.com with ESMTPSA id j5-v6sm4882292pfc.56.2018.07.03.21.51.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Jul 2018 21:51:39 -0700 (PDT) From: Jaejoong Kim To: =?UTF-8?q?Micha=C5=82=20Nazarewicz?= , Alan Stern , Felipe Balbi , Greg KH , Krzysztof Opasiak Cc: USB list Subject: [PATCH V2 1/2] usb: gadget: storage: Add error handling for no memory Date: Wed, 4 Jul 2018 13:51:27 +0900 Message-Id: <1530679888-19939-2-git-send-email-climbbb.kim@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530679888-19939-1-git-send-email-climbbb.kim@gmail.com> References: <1530679888-19939-1-git-send-email-climbbb.kim@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fsg_common_set_num_buffers() may fail due to ENOMEM. So add error handling for fail case. Acked-by: Alan Stern Acked-by: Michal Nazarewicz Signed-off-by: Jaejoong Kim --- Changes in V2: Add Acked-by drivers/usb/gadget/function/f_mass_storage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index acecd13..1b580eb 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -3308,7 +3308,9 @@ static ssize_t fsg_opts_num_buffers_store(struct config_item *item, if (ret) goto end; - fsg_common_set_num_buffers(opts->common, num); + ret = fsg_common_set_num_buffers(opts->common, num); + if (ret) + goto end; ret = len; end: