From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAEEE2DAFBD for ; Sat, 18 Jul 2026 04:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784350603; cv=none; b=i9H++/vm0/jbSJ81o4WT1dHJesFneUXjr0FrVhsgrZzJ4gKbyjm24W5ZGiT39hqhz+SWjTXZMMTzLgq1HFAEA9CdHJ6uTUu5xr+RDBj4kuarUUm8sKqIn1EDDYz9Eg+y5QhzwqmTqvG9ZaRDWX9d3Xe28Yuzb+4UX2mXxr4z5B8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784350603; c=relaxed/simple; bh=yOHVjWdXntfwJJZoiqbgwLQwPBj2c26COHkIdMjFbN4=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=U6RoTcw1Chk7pO/jhCw5wgLk/q9jLkp1GNN7/jjxeMpEfWNaUO+ws3h0O/JAPNUpW6MsHTzlEJfxMaWYMvKifm66+LQdGk6VX35tDCUHLRvaji5LCScPsMbjYvldlPSU4KvxfPT8IqAxZN57ETxSL5TjOCa8tU6i+kzzjMiLjiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=dt1A6Ymb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="dt1A6Ymb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AD5B1F000E9; Sat, 18 Jul 2026 04:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1784350602; bh=aKx16FvIe17FkU8a0wW0BFgAB8NW98Vxpm6HQ7lKaRs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=dt1A6YmbDlxMX4V0/5SiOh1Cy7KKNel+GgE006O8T0Zk54Q+ZViBB8ExEB5PfZ55H dk4KalsHxJq48tvNH4Enp5IAsXS13Tz+DvoseWbrmRjSrvYDmma6TSn+T1jtHZXkuO 4Q396iLC/lre3zPL+UJKKBC5633AZiiHcwonsYB4= Date: Fri, 17 Jul 2026 21:56:42 -0700 From: Andrew Morton To: Jackie Liu Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib: cpu_rmap: reject zero-sized maps Message-Id: <20260717215642.9e4b74a29e0b3afa2ee45938@linux-foundation.org> In-Reply-To: <20260718042155.31020-1-liu.yun@linux.dev> References: <20260718042155.31020-1-liu.yun@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Sat, 18 Jul 2026 12:21:55 +0800 Jackie Liu wrote: > From: Jackie Liu > > alloc_cpu_rmap() assigns an object index to each possible CPU using > cpu % size. Passing zero therefore triggers a divide error instead of > reporting that the map cannot be allocated. Is there any situation in which this is known to trigger? > Reject zero along with sizes that do not fit in the u16 map indices. If passing zero is a caller bug then a divide-by-zero exception is a fine way of reporting it. So I'm not seeing a need to make any change here.