Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp15718lqb; Thu, 23 May 2024 09:31:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrFpplKmLR+350vg3H3uPQEvLDbhbHz9IaTfs7hwodBtIcWQnSQMot/8RcF3YNdxV6aUMTnhDxZY/L9nxpRt4A2LV/ruiFQVOTZDmC2A== X-Google-Smtp-Source: AGHT+IHdeHMymJ0v51yDMfRFTWoZor1OYb+8npnJGmy0xt+bXY2L+9DrkVFBadtc2D1BenYw1+QE X-Received: by 2002:a50:8a96:0:b0:570:5b3d:91f with SMTP id 4fb4d7f45d1cf-57832a88f66mr3254928a12.23.1716481865841; Thu, 23 May 2024 09:31:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716481865; cv=pass; d=google.com; s=arc-20160816; b=DSx7uUYbzcR2lkyOoPkMXiwMcbYGIiDzuscyhNA2gqfN6uER2c5WARXbT8kpZbut7/ 4epmkcJRbP+cSfLMzEhiyCaBgR7hm2cdkmMEYPCVcEIzvEBXKpcc37v8I7yDNTiqC92+ rbYRI+Hic/LcvSvCgCB6/Dlj5ztzb+QkGeUw6lRx5h5lylR3i7EHUZ6k+GYsykgvY+9m MkvjbMjk9vwuR+Q851J8IDZdEIMpr3oS5Ou1cHVwP90E84SNYQ2v8ai4wR348IE+DYQ4 ejxaleI5Pndt9O/CH8XizG8upMNTwopWpTvRT9XojHOlqb7u6MvJqjuPPBjw+CuMsrEG Qq4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=bgyZuvM4CwEyx/dV0q7Gr5xs885li8qfCrHV6XxksUs=; fh=DHYxaMj/BRrwemWbzAIymvHEhpsz/OvuKDsR8+pFfZY=; b=Xqk6vrVHT5H16fWPsZ9WXLK8KocmUdrfjF4+9oW/W7c/dy7nykoh7vxNv/B5BuhjYu KFvuTqNsFYRV9DLSAlTrbgYMGuYa6bQ8mjlB0rbik3dzJtS1zHsPhXK5azRpx0VkO+wg 4QExqgS36TO0snmZGOV1MMq7DTISCeJNv+c7CufL48rf9wRQdVWyByRy4eicucOeL7SS XFYpF0Hh0sMRbeFv2IqrSGnODjUwdYjAGippMPEtiBozeCX41lFgMzs4u9dQOVicNV98 cos89TlwsgJW53TQFegylbQLmE1vSIQnnucPQ48lM4jVqXyrQfCwyRDv8u0O1e5ySwCW Jz0A==; 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-187782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574ef8fb9casi10130143a12.508.2024.05.23.09.31.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 09:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-187782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187782-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8833A1F22DFB for ; Thu, 23 May 2024 16:31:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02FB318633; Thu, 23 May 2024 16:30:56 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id C9D02B65D for ; Thu, 23 May 2024 16:30:53 +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=1716481855; cv=none; b=USwXFSVKUk+bdcuzYiuCsVaoUr5EjNpJR4QQlnMF9hTsYY/sOF0OjAOWZ9uEOr8JwJwkqBMKTTHDT52h6NSMpOsbH7B3dQm5XMHOppkDUj+LGgpaKMGe1MOJUHuF3NHyMFOcLjzkHx4qfDt7S3Q3Q2B3qTCq+sFjec/4DFsftWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716481855; c=relaxed/simple; bh=zsvWlc1vONWVLufrWVoYcSWo8o0jgMR2VZPSYk4F15E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nmcVN5g+SUExkyfqkqC9uKoh4LP2gDMeRa8sZhSembPKnb5DZ+lpgqE2Sx7SSSKoCtQPMbBgVbOj/a7S3TFIz2HSSiM1dbsK7NlcMpm87LhJKZGDvQEaBVtXl+WZ5p1B76NLLSzW7C9vfINmg92UInl05O+uQyw41iON32HaVzw= 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 543687 invoked by uid 1000); 23 May 2024 12:30:52 -0400 Date: Thu, 23 May 2024 12:30:52 -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=us-ascii Content-Disposition: inline In-Reply-To: On Thu, May 23, 2024 at 11:13:08PM +0800, shichao lai wrote: > Thanks for your comprehensive analysis. > I added some pr_info() to check the workflow, and I found that the > uzonesize was not initialized in fact! > > The workflow is shown as below. > Before alauda_read_data(), there are in fact many alauda_check_media(), > but none of them enter the branch of alauda_init_media(), where > uzonesize is set to nonzero value. > The key branch condition is "status[0] & 0x08", which is always > unsatisfied in this repro. > > ``` > alauda_transport > alauda_check_media > if (status[0] & 0x08) // not satisfied > alauda_init_media() > // initialize uzonesize > alauda_read_data > ``` 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