Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-18995

Incorrect check for null from container_of()

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • Lustre 2.17.0
    • Lustre 2.17.0
    • 3
    • 9223372036854775807

    Description

      Smatch highlight this incorrect pattern where we do an container_of from obd_device and then check it for null. Since the item we are looking for (kobj) is not the first item, the check is wrong.

       637 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
       638                                   const char *buffer, size_t count)
       639 {
       640         struct obd_device *obd = container_of(kobj, struct obd_device,
       641                                               obd_kset.kobj);
       642         struct obd_import *imp;
       643         bool val;
       644         int rc;
       645 
       646         if (obd == NULL)
       647                 return 0;

      We probably should drop all these checks as otherwise we'd long be crashing all around even before these accesses?

      Functions affected:

      stats_free, checksum_type_show, checksum_type_store, grant_shrink_store (twice, one in mdc and one in osc)

      Attachments

        Activity

          People

            wc-triage WC Triage
            green Oleg Drokin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: