Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp636604iog; Mon, 13 Jun 2022 09:36:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrtdpdmjpY+bDg23RAVMZQzODX2zTvDKC9Kvv0tjyqAmPpbthmYL3PgqCp2ReEr3iGJ32X X-Received: by 2002:a17:90a:6747:b0:1e6:6a5b:f040 with SMTP id c7-20020a17090a674700b001e66a5bf040mr17064588pjm.134.1655138195603; Mon, 13 Jun 2022 09:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655138195; cv=none; d=google.com; s=arc-20160816; b=xFJEmMey6eM9RYXFrjwxsTSYjp7oZnRW4CtOEQ3vCry7TiJgDKEK/0mvhRIMvr5HA3 qCJZ50Ij3b/jYBBqwTn5pqx+LczYh5YwkY8Vc7oSGNBMcR+n0y91y3/4V8dM+ElwNBl1 HXHf4qDM+zU8BXK5kU3ADwKEtN0aMTCt+IEMoOFtEUczco5Z3IuNQIAxMTmsLTl13GAz 6f8CXzzYKRgv9cRHaaIt75mWOuK6GPUZGk1TBMO0oewn1WQMzMZH7GwWjwyLBSsR8/tc N9InlE+aiyoeRC/fNBnzgNUkVoUj5we+SpdgoU/VFMytF1mRZWiNWKhSFqCXrg0w/OoG xa8Q== 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=j1ZG54YVlECCRtAZX+IQsZai4za0sNzsT6pCuGG3T+8sXngyhbqNdE4vF9UOE6KlnI bRdHrkrws345uZARwXfRLw+kU+FJr0gF+G4LVwqS9XQ3TmQkxnSVhsgxCYgVJWIEyXVD 4BJ0yUfUezmTgIv34B3bslpRve/1Yw3Ik8+UrRlNfZCD3+7tV5IdRCKVcTjKjZmKzL9M OsqCmptjtv+7nt/h/EEDkwqqJld4il+JK/P96Wg7wnfTRMRAFye/tM+I72qNLFuPkbaT yT/XRveqwID6Lqvy1kwDqMICmh6D82cIXSBQjdoRf4g+bQHNJBsWETvuK8xLk2QdrSFI OD7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zw3QeFh3; 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 np7-20020a17090b4c4700b001e6f83a6998si17027218pjb.56.2022.06.13.09.36.23; Mon, 13 Jun 2022 09:36:35 -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=zw3QeFh3; 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 S1377423AbiFMN0v (ORCPT + 99 others); Mon, 13 Jun 2022 09:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377295AbiFMNYu (ORCPT ); Mon, 13 Jun 2022 09:24:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E346C0C8; Mon, 13 Jun 2022 04:24:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id 597DEB80D31; Mon, 13 Jun 2022 11:24:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29CFC34114; Mon, 13 Jun 2022 11:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119449; bh=T7zgCZdrnSI9zOst5mi3apWNt045/z6rDMsSMmV8L38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zw3QeFh3/luXXyvZLKCxKTDqaQN17STLeW48+wsPlH+fBAPTkcvPcWmIISn3CyPbH HMNMvUGeQ35FtMrhuCMfVMtMlXT2QjHLExLTGrP0jAYvXG7iv6++yYrqunT3oOJKRg eDxnE9+ZtzTVlcVzx9jugdKRVZi2AU1I8367FLmQ= 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.18 019/339] USB: storage: karma: fix rio_karma_init return Date: Mon, 13 Jun 2022 12:07:24 +0200 Message-Id: <20220613094927.090625175@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@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