Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbdIURje (ORCPT ); Thu, 21 Sep 2017 13:39:34 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57094 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbdIURjd (ORCPT ); Thu, 21 Sep 2017 13:39:33 -0400 Date: Thu, 21 Sep 2017 18:39:15 +0100 From: Al Viro To: Thomas Meyer Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] ALSA: emu10k1: Cocci spatch "alloc_cast" Message-ID: <20170921173914.GK32076@ZenIV.linux.org.uk> References: <1505975570447-826702259-0-diffsplit-thomas@m3y3r.de> <1505975570447-568224618-4-diffsplit-thomas@m3y3r.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1505975570447-568224618-4-diffsplit-thomas@m3y3r.de> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1205 Lines: 27 On Thu, Sep 21, 2017 at 08:33:46AM +0200, Thomas Meyer wrote: > Remove casting the values returned by memory allocation functions like > kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc." > Found by coccinelle spatch "api/alloc/alloc_cast.cocci" > > Signed-off-by: Thomas Meyer > --- > > diff -u -p a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c > --- a/sound/pci/emu10k1/emufx.c > +++ b/sound/pci/emu10k1/emufx.c > @@ -1218,7 +1218,7 @@ static int _snd_emu10k1_audigy_init_efx( > if (!icode) > return err; > > - icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, > + icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, > sizeof(u_int32_t), GFP_KERNEL); And _this_ is a wonderful example of the reasons why that kind of patches is bloody bad. The code you've caught is very obviously smelly - kcalloc() does *NOT* return a userland pointer. You are whitewashing it; a major "something weird is going on here" sign is gone (something weird in that case is hopefully a set_fs(KERNEL_DS) somewhere nearby, and it is asking for careful review). FWIW, any patches of that sort anywhere near VFS are very much not welcome.