From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbdHPNam (ORCPT ); Wed, 16 Aug 2017 09:30:42 -0400 Received: from mout.web.de ([212.227.17.12]:51968 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbdHPNai (ORCPT ); Wed, 16 Aug 2017 09:30:38 -0400 Subject: [PATCH 2/2] UBIFS: Improve 19 size determinations From: SF Markus Elfring To: linux-mtd@lists.infradead.org, Adrian Hunter , Artem Bityutskiy , Richard Weinberger Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Wed, 16 Aug 2017 15:30:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 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:mlc7NrqKthw9RbDXi8g8uxaXN7KYt7wdZpSUNbrWxjTB6KVBwMJ 0zpiQ528S/40LXYAjSCcgy2XpnCStuR10SfDK6BTTR2a4pCXLZHt0QYqTVC9/1Ggmwjezrm S3fbfMpiopsHd6oHUQIN82YuuW430lyvebV+352HbPNm8Z4hxucuIeEuzeJ8OsKN0vQ9jDY fYem7PHlo6gnM+cpbzorQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:qRwKGX8Xelc=:pVnx3t3LliV0NOBNF97gcF dXyTbv/Tum6qA7z5itNucL8oi5KygkwjPkz4OCfPqM5L41NsPl8CU5pMeOB9fYkSqPJJW/+MJ 1tWhu/hoGC9+iRovMHV1xc3cbRYTXoyf+uGlwfJnVwqMIkHFn7z6RDsT+jhzFU8v6VUl7+AZZ geKvgsH1MgwF2UkzoWTn/819SvZ9xdyLi1p97bZyRvZvfUHeqaOLgm6ayYeQWJerRZdiT8HYE XY5GmW7kPXyW/j2Qn682oCzAdrutvSsAjT4xhS4TaC2SxgwPR0fBIPFm4ZRpdzVaoFmsoPCqO btyWsO04fTkqRGnptkpn0szdK0zX69Rgm1+fqzZ7ECqlB4S0BIh0/9qmyXqRUGpbsg8Ej/TpM W2FhS1inwimRsru4QdgS0wZnAZhBDEYg1ebfu7BYmRQbB3zhvI2XIqWX49XVEnRfYx8r/yihG OXBPaoSNyAxU0jsFi6+5JVBXZxnzD18f4uw1hmIGkNnEXmZNbSmVJultaiiJnaCzA4THeTcGW 4xGFKLipQrPX9cv0ojwlzR1zLqkmbR/BhG6AfZ4apAubdCOF+hZ4l0YxW5QEZV+FE3Mo5HdEw v8zR1iiEpT2W+QlmOL5E55hAUryca2C5uCiVirbYY5E+zcasCLU4ftupP/ANsj+uSBXwl45Jd q0thopZABHri9/TodxvDcOIV+Qy296ZisKheK5yLdRma49PLgvJKM23sJk9J9LJwrkHk/EBZF G8JI/qcRLdrub57kaLT3Ikw/hFlHHutSPwcMCptGyJM4oFYnoii6KI1MwznXhob2pRsij7IOF e/OhyHMKewyhYhPwWD2EuCrfgYhuqDoDZP2WPf2F61YUMP5iwA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Wed, 16 Aug 2017 14:14:28 +0200 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 --- fs/ubifs/log.c | 2 +- fs/ubifs/lpt.c | 12 ++++++------ fs/ubifs/orphan.c | 6 +++--- fs/ubifs/recovery.c | 2 +- fs/ubifs/replay.c | 8 ++++---- fs/ubifs/scan.c | 4 ++-- fs/ubifs/super.c | 2 +- fs/ubifs/tnc.c | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index 8c795e6392b1..cd19f2c28b3d 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c @@ -179,7 +179,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) struct ubifs_bud *bud; struct ubifs_ref_node *ref; - bud = kmalloc(sizeof(struct ubifs_bud), GFP_NOFS); + bud = kmalloc(sizeof(*bud), GFP_NOFS); if (!bud) return -ENOMEM; ref = kzalloc(c->ref_node_alsz, GFP_NOFS); diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 9a517109da0f..014614a62522 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c @@ -629,8 +629,8 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, c->main_first = c->leb_cnt - *main_lebs; lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_KERNEL); - pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL); - nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL); + pnode = kzalloc(sizeof(*pnode), GFP_KERNEL); + nnode = kzalloc(sizeof(*nnode), GFP_KERNEL); buf = vmalloc(c->leb_size); ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); if (!pnode || !nnode || !buf || !ltab || !lsave) { @@ -1205,7 +1205,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) lnum = c->lpt_lnum; offs = c->lpt_offs; } - nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_NOFS); + nnode = kzalloc(sizeof(*nnode), GFP_NOFS); if (!nnode) { err = -ENOMEM; goto out; @@ -1268,7 +1268,7 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) branch = &parent->nbranch[iip]; lnum = branch->lnum; offs = branch->offs; - pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS); + pnode = kzalloc(sizeof(*pnode), GFP_NOFS); if (!pnode) return -ENOMEM; @@ -1498,7 +1498,7 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c, } /* nnode is being committed, so copy it */ - n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS); + n = kmemdup(nnode, sizeof(*n), GFP_NOFS); if (unlikely(!n)) return ERR_PTR(-ENOMEM); @@ -1548,7 +1548,7 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c, } /* pnode is being committed, so copy it */ - p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS); + p = kmemdup(pnode, sizeof(*p), GFP_NOFS); if (unlikely(!p)) return ERR_PTR(-ENOMEM); diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index f5b01f9f9985..05e4136fa090 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c @@ -67,7 +67,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum) struct ubifs_orphan *orphan, *o; struct rb_node **p, *parent = NULL; - orphan = kzalloc(sizeof(struct ubifs_orphan), GFP_NOFS); + orphan = kzalloc(sizeof(*orphan), GFP_NOFS); if (!orphan) return -ENOMEM; orphan->inum = inum; @@ -514,7 +514,7 @@ static int insert_dead_orphan(struct ubifs_info *c, ino_t inum) struct ubifs_orphan *orphan, *o; struct rb_node **p, *parent = NULL; - orphan = kzalloc(sizeof(struct ubifs_orphan), GFP_KERNEL); + orphan = kzalloc(sizeof(*orphan), GFP_KERNEL); if (!orphan) return -ENOMEM; orphan->inum = inum; @@ -771,7 +771,7 @@ static int dbg_ins_check_orphan(struct rb_root *root, ino_t inum) struct check_orphan *orphan, *o; struct rb_node **p, *parent = NULL; - orphan = kzalloc(sizeof(struct check_orphan), GFP_NOFS); + orphan = kzalloc(sizeof(*orphan), GFP_NOFS); if (!orphan) return -ENOMEM; orphan->inum = inum; diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 3af4472061cc..e9821820b260 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c @@ -1269,7 +1269,7 @@ static int add_ino(struct ubifs_info *c, ino_t inum, loff_t i_size, p = &(*p)->rb_right; } - e = kzalloc(sizeof(struct size_entry), GFP_KERNEL); + e = kzalloc(sizeof(*e), GFP_KERNEL); if (!e) return -ENOMEM; diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index ae5c02f22f3e..479d871a8573 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c @@ -365,7 +365,7 @@ static int insert_node(struct ubifs_info *c, int lnum, int offs, int len, if (key_inum(c, key) >= c->highest_inum) c->highest_inum = key_inum(c, key); - r = kzalloc(sizeof(struct replay_entry), GFP_KERNEL); + r = kzalloc(sizeof(*r), GFP_KERNEL); if (!r) return -ENOMEM; @@ -412,7 +412,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len, if (key_inum(c, key) >= c->highest_inum) c->highest_inum = key_inum(c, key); - r = kzalloc(sizeof(struct replay_entry), GFP_KERNEL); + r = kzalloc(sizeof(*r), GFP_KERNEL); if (!r) return -ENOMEM; @@ -750,11 +750,11 @@ static int add_replay_bud(struct ubifs_info *c, int lnum, int offs, int jhead, dbg_mnt("add replay bud LEB %d:%d, head %d", lnum, offs, jhead); - bud = kmalloc(sizeof(struct ubifs_bud), GFP_KERNEL); + bud = kmalloc(sizeof(*bud), GFP_KERNEL); if (!bud) return -ENOMEM; - b = kmalloc(sizeof(struct bud_entry), GFP_KERNEL); + b = kmalloc(sizeof(*b), GFP_KERNEL); if (!b) { kfree(bud); return -ENOMEM; diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index aab87340d3de..1a0c98ac410c 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c @@ -142,7 +142,7 @@ struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum, dbg_scan("scan LEB %d:%d", lnum, offs); - sleb = kzalloc(sizeof(struct ubifs_scan_leb), GFP_NOFS); + sleb = kzalloc(sizeof(*sleb), GFP_NOFS); if (!sleb) return ERR_PTR(-ENOMEM); @@ -198,7 +198,7 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, struct ubifs_ino_node *ino = buf; struct ubifs_scan_node *snod; - snod = kmalloc(sizeof(struct ubifs_scan_node), GFP_NOFS); + snod = kmalloc(sizeof(*snod), GFP_NOFS); if (!snod) return -ENOMEM; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index bffadbb67e47..9723c08fcbd1 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1965,7 +1965,7 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi) { struct ubifs_info *c; - c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); + c = kzalloc(sizeof(*c), GFP_KERNEL); if (c) { spin_lock_init(&c->cnt_lock); spin_lock_init(&c->cs_lock); diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 0a213dcba2a1..276233dff9bf 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c @@ -84,7 +84,7 @@ static int insert_old_idx(struct ubifs_info *c, int lnum, int offs) struct ubifs_old_idx *old_idx, *o; struct rb_node **p, *parent = NULL; - old_idx = kmalloc(sizeof(struct ubifs_old_idx), GFP_NOFS); + old_idx = kmalloc(sizeof(*old_idx), GFP_NOFS); if (unlikely(!old_idx)) return -ENOMEM; old_idx->lnum = lnum; -- 2.14.0