Fixed potential memory leak when bdgr_init() fails before a key is created