Skip to contentSkip to conversation

bug report: potential null dereference

DISCUSSION Dan Carpenter 2 participants 2 messages May 25, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

This is a Smatch thing.

fs/ceph/auth.c +220 ceph_handle_auth_reply(55) error: potential null derefence 'ac->ops'.
211 /* set up (new) protocol handler? */
212 if (ac->protocol && ac->protocol != protocol) {

   213                          ac->ops->destroy(ac);
   214                          ac->protocol = 0;
   215                          ac->ops = NULL;
                                ^^^^^^^^^^^^^^^
	We set ac->ops to NULL here.

216 }
217 if (ac->protocol != protocol) {
218 ret = ceph_auth_init_protocol(ac, protocol);
219 if (ret) {
220 pr_err("error %d on auth method %s init\n",
221 ret, ac->ops->name);
^^^^^^^^^^^^^^
We dereference it here. ceph_auth_init_protocol() can fail before re-assigning it.

222 goto out;
223 }
224 }

regards,
dan carpenter

#1 lore raw
Quoted 18 lines · Dan Carpenter

Hello,

This is a Smatch thing.

fs/ceph/auth.c +220 ceph_handle_auth_reply(55) error: potential null derefence 'ac->ops'.
211 /* set up (new) protocol handler? */

   212                  if (ac->protocol && ac->protocol != protocol) {
   213                          ac->ops->destroy(ac);
   214                          ac->protocol = 0;
   215                          ac->ops = NULL;
                                ^^^^^^^^^^^^^^^
	We set ac->ops to NULL here.

   216                  }
   217                  if (ac->protocol != protocol) {
   218                          ret = ceph_auth_init_protocol(ac, protocol);
   219                          if (ret) {
   220                                  pr_err("error %d on auth method %s init\n",
Quoted 8 lines
   221                                         ret, ac->ops->name);
                                                    ^^^^^^^^^^^^^^
	We dereference it here.  ceph_auth_init_protocol() can fail
	before re-assigning it.

   222                                  goto out;
   223                          }
   224                  }

Thanks, I've queued up a fix.

sage