Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608AbeAFPKX (ORCPT + 1 other); Sat, 6 Jan 2018 10:10:23 -0500 Received: from mout.web.de ([212.227.15.3]:60156 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752724AbeAFPKW (ORCPT ); Sat, 6 Jan 2018 10:10:22 -0500 Subject: [PATCH 3/5] mtd/rfd_ftl: Improve a size determination in two functions From: SF Markus Elfring To: linux-mtd@lists.infradead.org, Boris Brezillon , Brian Norris , Cyrille Pitchen , David Woodhouse , Marek Vasut , Richard Weinberger Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Sat, 6 Jan 2018 16:09:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:IFPaM2ed2dhTUg/E18Z9/YC1arrVRLM4gnHftg5WwuRS/oziwfo BPDXNnOabiWIzHO0FFWxLEk1GkQAJ6pjA+qOHdpXWCituwxgIdUhOKF6jCkMeMl7f6W3Y8z 3097kEXAo/cLMAJgjszx3g3syFfvzEpmdLRUL5TNs1bDfTU7M9k8fjCLEMzUvwodYf/cqNI VZOy1dDCcfCy+KesRMPgQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:lNVXpI88+50=:hcmSZa3knntMF+tewTaCbi 4Ps8Nz0R94e8FFpyMDDVPXQpuGFPZOySBsCLVh+02f+5fWxaXan21Qna3cs0Ew730k8jSvi3G G0yDieUkNZ7DHKcf/ssF6HeSMLJwrX0MFPxl8yDpb4+jUl98+5t7NbfgFHxSOewKsY/PoiMS9 docGcaVowXmWcM1GiLu7CtcRpa5O2XxCeht1EC9blHWtDGwfPkoMtHEaBCo1h0AFTNlYobjs4 8WMBpFGtERHmEyxqr7F6m4yTS70gIREo901uJeAUmAd+nrUt5Lf5poJuTUXzKCyO36n5MiGq1 dvFiaCqoaPzI+tFEnwgWvbUQ8tRFJXgIiCrAez0hN21Bf576y9a0QszOcBLGlf5GGqTVQQwps LXmJJ8537/nAboUZbfPdogMlMR0gbXaMyVkxa7GsQf8Z2jXLqS2lmFbho+jimyLFt1s3HO3Hz aDJKDO61ZsqWySxgTvjuN8GVGXcbMwD0kkAaazF0iJlDd39A4rs/IzOFB+084Sl6Xl6lit9/f INDSB7k1WKEMi/wN5OSgBsMpT+za9Y3SCYigyH9CmBwa5XERMl2nMZ/hgwmB3FKfLFMtcYehr Jkh3ipdPt9PIGU6ZRXWW3jGxQUslR8ohgQxu2SYRYZwH3S1ji/v+7z7mkUK6SkZqnmy7HErHQ UpIVBlrJt7q5+I9bUYsKlDgxmOkBnHru93xLOi/T+svhYDCuGAh5s32venP0JVYSRzXOWDMp8 /nvBrOdoJhNazuWZ6Y5lzmL3SWi87WxBRgNhs72JYxb9P7DWCUQJC+AUIya9LU/mf/UWez1U9 UPNrrE9YUSNZePLdnpgb4Zm/q6wqpZHtUPRvlycivMAbGaVjw0= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Markus Elfring Date: Sat, 6 Jan 2018 15:03:29 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/mtd/rfd_ftl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 19e14f909dc6..dcf1b88e1193 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -323,10 +323,9 @@ static void erase_callback(struct erase_info *erase) static int erase_block(struct partition *part, int block) { - struct erase_info *erase; int rc = -ENOMEM; + struct erase_info *erase = kmalloc(sizeof(*erase), GFP_KERNEL); - erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL); if (!erase) goto err; @@ -759,7 +758,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX) return; - part = kzalloc(sizeof(struct partition), GFP_KERNEL); + part = kzalloc(sizeof(*part), GFP_KERNEL); if (!part) return; -- 2.15.1