From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754465AbdEQJXv (ORCPT ); Wed, 17 May 2017 05:23:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:49314 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753219AbdEQJXt (ORCPT ); Wed, 17 May 2017 05:23:49 -0400 Date: Wed, 17 May 2017 11:23:44 +0200 From: Michal Hocko To: Chris Wilson Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Daniel Vetter , Jani Nikula , Sean Paul , David Airlie Subject: Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Message-ID: <20170517092344.GI18247@dhcp22.suse.cz> References: <20170517065509.18659-1-mhocko@kernel.org> <20170517073809.GJ26693@nuc-i3427.alporthouse.com> <20170517090350.GG18247@dhcp22.suse.cz> <20170517091241.GL26693@nuc-i3427.alporthouse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170517091241.GL26693@nuc-i3427.alporthouse.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 17-05-17 10:12:41, Chris Wilson wrote: > On Wed, May 17, 2017 at 11:03:50AM +0200, Michal Hocko wrote: [...] > > +static inline bool alloc_array_check(size_t n, size_t size) > > +{ > > + if (size != 0 && n > SIZE_MAX / size) > > + return false; > > + return true; > > Just return size == 0 || n <= SIZE_MAX /size ? > > Whether or not size being 0 makes for a sane user is another question. > The guideline is that size is the known constant from sizeof() or > whatever and n is the variable number to allocate. > > But yes, that inline is what I want :) I will think about this. Maybe it will help to simplify/unify some other users. Do you have any pointers to save me some grepping...? -- Michal Hocko SUSE Labs