Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp909605lqb; Fri, 24 May 2024 19:24:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfaxaEOp4PkTRB6f5nCPgabKlYIj2Ftt5TL8YiJQUwUD6e5jZBwPnBNfuLj0WKT8R/aA4h1KpJZax6jXrT9XKCJylQO6cMcAp8BskbjQ== X-Google-Smtp-Source: AGHT+IHCjOZE7YL1tz6Gq6popEc+oFrBrmQt55q7RgASDgGM2OnDcD7lLFL1ODa5E7oF/BAIszvZ X-Received: by 2002:a05:6214:5c08:b0:6ab:891c:54eb with SMTP id 6a1803df08f44-6abcd0ae9b6mr37703606d6.34.1716603882267; Fri, 24 May 2024 19:24:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716603882; cv=pass; d=google.com; s=arc-20160816; b=yJx8taNbwzFXg2QDgujoWv8HT6KL3sipPITBmpR+weSK7iOY/MFPnWI722jT+dl23M V9JQWzWx/pGjTK78MOXK6sEReEQgNGEzHtaHG142f+BZG2g8b1ulPZ2aI7Zc1DTUDxDo 7WC9gz2uc7BuFX4q4Y2x+jwNuVesN/xxB4nyD4yuv/tq06D8mq/K3fvilZpHlNN7naFu k0EPJCc2112FJLqeIuxSa82NvWs78+QVwkQNvnJFnkSk4sCdGT6EOobdZ1M+6bXpnOMG eK446sVKQsE82DMjeO0H43IljXqIDWHM2G3G3KHMHiS92M7sVp7u67d4JAXhdUvfp3gB pc0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=TvzRjMWTi5xy+tBOOmq6HczATWcgg7nYmAf6XDLGHQY=; fh=DHYxaMj/BRrwemWbzAIymvHEhpsz/OvuKDsR8+pFfZY=; b=Fe3IqzWqkB44JLeBeTL9PGrA+urrU96q26GJRKkL7EUS94K8ekBQOuQMtMSnHzVnVK fFtV+CcM1nF8+ZvgrtOWiBIgGiTnU9l85frIyB6oPSGvsugTW9SfCop+zpYHp+VXWpa/ C653tnKLAHks4YktEPpvGyGSYH4OBW4KFkskk/S1dFUrZs5KedqsReoTOy5riD4ZBsE9 5wbgENZ1ljETPcXdJxeVtw0JaUtBh6Out+dnHLQt5AkuoooOnisWzIshbmVdEyXzREQg fROoQXbv2DZeD5Qt371ygwwO9Y63Ghi6HiemFMvCv/4Ha17rfExnSxoPXY7j1L1tvBM9 Ni5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-189238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac162d65c7si29424716d6.566.2024.05.24.19.24.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 19:24:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-189238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DB90A1C20A08 for ; Sat, 25 May 2024 02:24:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E68DF2119; Sat, 25 May 2024 02:24:33 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 8718410E3 for ; Sat, 25 May 2024 02:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716603873; cv=none; b=kuXXY1oPX0dWKeXFbbSUG59IJXEttjGTVJhRSqgJi3IsUK+EY46sHGQGMsdBIVDqGNsBrTgZBZwWXwFQ9G4zSfcqo9oRudYS0cf52jnVgbp/9tB0AJQeGkRbnAq9quI/JF3tzJDa5ecj2YF6xfc9bXQoWed7CJBdgmtyXhv6Pl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716603873; c=relaxed/simple; bh=7tUhIHfBn34z7qtBCeiL2raRXN+auBPYGV8rte3VEp8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AtQPgHhRfZcmAg5IQZPxd+NByeD8oNbigX3u1kqDNn2bOwZtcJNUZM9xW205C77j+A05BVbV4R5+gvU8fTXKR4YIlzVEeO2LCSX7CrVTgmVhCQeoMO5Ua1wnXPm5ianxLzf+BVbBPrsBvSkH2kL7JJEReQhoERzTTXUWBmdkfOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 594160 invoked by uid 1000); 24 May 2024 22:24:24 -0400 Date: Fri, 24 May 2024 22:24:24 -0400 From: Alan Stern To: shichao lai Cc: gregkh@linuxfoundation.org, oneukum@suse.com, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, xingwei lee , yue sun Subject: Re: [PATCHv2] Check whether divisor is non-zero before division Message-ID: References: <20240523092608.874986-1-shichaorai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, May 24, 2024 at 10:13:45AM +0800, shichao lai wrote: > On Fri, May 24, 2024 at 12:30 AM Alan Stern wrote: > > > > Good work! So the problem is that the driver believes the status[0] & > > 0x08 test. > > > > The way to fix this is to add an "initialized" flag to the alauda_info > > structure. Then alauda_check_media() should call alauda_init_media() if > > the 0x08 bit is set in status[0] _or_ if info->initialized is 0. And of > > course, alauda_check_media() should then set info->initialized to 1 if > > the alauda_init_media() call succeeds. > > > > Would you like to write and test a patch that does this? > > > > Alan Stern > > I tried to do this. And the workflow can enter alauda_init_media(), > but there are still many conditions to satisfy in alauda_init_media(). > Unfortunately alauda_init_media() stop and return here before > initializing uzonesize: > > if (data[0] != 0x14) { > usb_stor_dbg(us, "Media not ready after ack\n"); > return USB_STOR_TRANSPORT_ERROR; > } That's an error return. > The data[0] is status[0] showed before, and it was 0x0036. > I am not familiar with the status code of alauda. > How can I deal with this condition? > Is it ok to pass this condition when info->initialized == false, even > if the data[0] != 0x14? If alauda_init_media() returns an error, leave info->initialized unchanged. alauda_check_media() will return an error also, so the bad division won't take place. Alan Stern