[LU-11610] Incorrect use of PTR_ERR on valid pointers in out_handler.c Created: 03/Nov/18  Updated: 20/Jan/22

Status: Open
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.12.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Oleg Drokin Assignee: WC Triage
Resolution: Unresolved Votes: 0
Labels: easy

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

It looks like there's a lot of incorrect code like this:

        tmp = object_update_param_get(update, 1, &size);
        if (IS_ERR(tmp) || size != sizeof(*tmp)) {
                CERROR("%s: empty or wrong size %zu pos: rc = %ld\n",
                       tgt_name(tsi->tsi_tgt), size, PTR_ERR(tmp));
                RETURN(PTR_ERR(tmp));
        }

so it's clear when IS_ERR is true all is fine, but when sizeof does not match - the pointer is likely valid so some different handling needs to be made?

here's the total list of all offenders:
lustre/target/out_handler.c:120 out_create() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:122 out_create() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:134 out_create() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:136 out_create() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:173 out_attr_set() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:175 out_attr_set() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:442 out_xattr_set() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:444 out_xattr_set() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:539 out_index_insert() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:541 out_index_insert() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:555 out_index_insert() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:557 out_index_insert() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:642 out_write() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:644 out_write() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:651 out_write() warn: passing a valid pointer to 'PTR_ERR'
lustre/target/out_handler.c:653 out_write() warn: passing a valid pointer to 'PTR_ERR'



 Comments   
Comment by Andreas Dilger [ 20/Jan/22 ]

still an issue

Generated at Sat Feb 10 02:45:23 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.