Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442297iog; Mon, 13 Jun 2022 06:05:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTY/eYU7KQivpFqyZwFnTGBckD56j3+Qm5jWNxx9P++YnJ8ljMPEd3rcnsEmK3u2LPqr/l X-Received: by 2002:a17:907:2da6:b0:711:d86d:ccab with SMTP id gt38-20020a1709072da600b00711d86dccabmr33811815ejc.356.1655125443453; Mon, 13 Jun 2022 06:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125443; cv=none; d=google.com; s=arc-20160816; b=GVoHDTbDVZ8BHkFdgeRTn4M1wR1a0PTfvjVZZO+gRK+x3Kox3Wugd6huuUmoHjbgky pSSeopI0/YFf8psmFgF8vueIJUyApOAyyY/2PwtGHIZc/mptEzawUgrJcyuDPlVJ9+lx b72/x9UpgrVMSSnuYbuNhlT2dz5uax2ICRAVFqhkxwnG6nhVp9pWVQJK5UHfHEGCTTaF /qFplgGHcOha8UTgOd4OVNyijxokB+MkqwO6fOkEF9yvp/179e1CVH2xtV8B+Onshk/k OzBVTOjMXr0Z6aoJ/d7axXDiBfp7L6DjJ2pcBf4N27tMOb6Gyoz98aLSoNopg5NYVSYv qxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B5hOxrYzFucH8PQ+uWDURwtuOvAgPBH6Pnooj5e6iKQ=; b=tQrZoqWlvbFZ5UmzTIklG2+sJCRn0fuA4ZoJfNUyrXnh8bdqQX7OMFxYTEonSwIrUN cahAkd+/R8DDu3PLfWqJr3Gigth/ZcurdYS+WV6tYeUa4yzKGHxyMrScYj9+rRHqQevD kH5KRLy8iRMpxPvsXRQ14lSFcIt+noyIxfXhbWwkRQxQXkL9F3N7c/e5xnCGMexXN1Q9 gkvStEp6AoRWBBuPU8SDmJ/mWpgdZl6ne+6DFD93PkfobP7x/uj1XG25IS/k7YHirOrr EQKftiXf8IRdg3Dw1s1ch+1YKc2c/Y0RwgtUFqM47Wp2M5RcqWfuHf1vAc4s4NHJz0H2 IHtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y3qImokI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i27-20020a170906265b00b006e88cc5c374si6413978ejc.179.2022.06.13.06.03.35; Mon, 13 Jun 2022 06:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y3qImokI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354960AbiFMLgh (ORCPT + 99 others); Mon, 13 Jun 2022 07:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354568AbiFML3n (ORCPT ); Mon, 13 Jun 2022 07:29:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE1ED20BD5; Mon, 13 Jun 2022 03:45:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6BBD960FDB; Mon, 13 Jun 2022 10:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77EE7C34114; Mon, 13 Jun 2022 10:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117107; bh=T7zgCZdrnSI9zOst5mi3apWNt045/z6rDMsSMmV8L38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y3qImokIKhLGLqCAnhp5gc9SV6kRMLH4b2SFae/6N81SAeGo6/SO8n+EnlNq5zRa+ uahkj3vC6tmmk2anGtYCY0/2gO2uibziozZf04CrfxQW/PuSbP433TfcEGNUv6X0Bx BGOzbogMcJPWAbJN3cc5joz+sWfRIKZoLGzA8RCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Lin Ma , Sasha Levin Subject: [PATCH 5.4 289/411] USB: storage: karma: fix rio_karma_init return Date: Mon, 13 Jun 2022 12:09:22 +0200 Message-Id: <20220613094937.425345309@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lin Ma [ Upstream commit b92ffb1eddd9a66a90defc556dcbf65a43c196c7 ] The function rio_karam_init() should return -ENOMEM instead of value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails. Similarly, it should return -EIO when rio_karma_send_command() fails. Fixes: dfe0d3ba20e8 ("USB Storage: add rio karma eject support") Acked-by: Alan Stern Signed-off-by: Lin Ma Link: https://lore.kernel.org/r/20220412144359.28447-1-linma@zju.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/storage/karma.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index 05cec81dcd3f..38ddfedef629 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c @@ -174,24 +174,25 @@ static void rio_karma_destructor(void *extra) static int rio_karma_init(struct us_data *us) { - int ret = 0; struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); if (!data) - goto out; + return -ENOMEM; data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO); if (!data->recv) { kfree(data); - goto out; + return -ENOMEM; } us->extra = data; us->extra_destructor = rio_karma_destructor; - ret = rio_karma_send_command(RIO_ENTER_STORAGE, us); - data->in_storage = (ret == 0); -out: - return ret; + if (rio_karma_send_command(RIO_ENTER_STORAGE, us)) + return -EIO; + + data->in_storage = 1; + + return 0; } static struct scsi_host_template karma_host_template; -- 2.35.1